{"id":21730112,"url":"https://github.com/nventive/chinooksnippets","last_synced_at":"2025-03-20T23:22:20.848Z","repository":{"id":45306195,"uuid":"301760764","full_name":"nventive/ChinookSnippets","owner":"nventive","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-27T17:56:42.000Z","size":336,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-03-17T11:55:10.459Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Vim Snippet","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nventive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-06T14:49:08.000Z","updated_at":"2024-05-27T12:50:42.000Z","dependencies_parsed_at":"2022-08-04T13:30:34.232Z","dependency_job_id":"27bb056c-037c-4a35-9ee7-12b5404107cc","html_url":"https://github.com/nventive/ChinookSnippets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"nventive/Template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nventive%2FChinookSnippets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nventive%2FChinookSnippets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nventive%2FChinookSnippets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nventive%2FChinookSnippets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nventive","download_url":"https://codeload.github.com/nventive/ChinookSnippets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244706777,"owners_count":20496621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-26T04:12:29.161Z","updated_at":"2025-03-20T23:22:20.829Z","avatar_url":"https://github.com/nventive.png","language":"Vim Snippet","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chinook Snippets\n\nVisualStudio Extension providing code snippets for Chinook libraries.\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n\n## Getting Started\n\n1. Install the `Chinook Snippets` Visual Studio Extension\n    * Download the `.vsix` directly from the [Visual Studio Marketplace - Chinook Snippets](https://marketplace.visualstudio.com/items?itemName=nventivecorp.ChinookSnippets).\n    * Install it directly in Visual Studio \u003cbr/\u003e ![image](/doc/images/vsstudioinstall.png)\n\n2. Start writing `ck` and a list of snippets will appear. Choose any of the available Chinook snippets and press the `TAB` key to execute the snippet.\n\u003cbr/\u003e ![image](/doc/images/firstsnippet.gif) ![image](/doc/images/firstsnippet2.gif)\n\n## Features\n\nExplore the powerful features of the Chinook Snippets Visual Studio Extension. Easily enhance your projects with dynamic properties, commands, and DataLoader support using these convenient code snippets.\n\n### DynamicProperty\nOn projects that uses [Chinook.DynamicMvvm](https://github.com/nventive/Chinook.DynamicMvvm), there are a couple of snippets available for creating dynamic properties. Writing `ckprop` will display all the available snippets. ![image](/doc/images/ckprop.png)\n\n#### From Observable\n\n- Write and execute `ckpropo` to create a two-way DynamicProperty from an observable.\n```cs\npublic int MyProperty\n{\n\tget =\u003e this.GetFromObservable\u003cint\u003e(ObserveMyProperty(), initialValue: 0);\n\tset =\u003e this.Set(value);\n}\n\nprivate IObservable\u003cint\u003e ObserveMyProperty()\n{\n\tthrow new NotImplementedException();\n}\n```\n- Write and execute `ckpropog` to create a one-way DynamicProperty from an observable.\n```cs\npublic int MyProperty =\u003e this.GetFromObservable\u003cint\u003e(ObserveMyProperty(), initialValue: 0);\n\nprivate IObservable\u003cint\u003e ObserveMyProperty()\n{\n\tthrow new NotImplementedException();\n}\n```\n\n#### From Task\n\n- Write and execute `ckpropt` to create a two-way DynamicProperty from a `Task`.\n```cs\npublic int MyProperty\n{\n\tget =\u003e this.GetFromTask\u003cint\u003e(GetMyProperty, initialValue: 0);\n\tset =\u003e this.Set(value);\n}\n\nprivate async Task\u003cint\u003e GetMyProperty(CancellationToken ct)\n{\n\tthrow new NotImplementedException();\n}\n```\n- Write and execute `ckproptg` to create a one-way DynamicProperty from a `Task`.\n```cs\npublic int MyProperty =\u003e this.GetFromTask\u003cint\u003e(GetMyProperty, initialValue: 0);\n\nprivate async Task\u003cint\u003e GetMyProperty(CancellationToken ct)\n{\n\tthrow new NotImplementedException();\n}\n```\n\n#### From Value\n\n- Write and execute `ckpropv` to create a two-way DynamicProperty from a value.\n```cs\npublic int MyProperty\n{\n\tget =\u003e this.Get\u003cint\u003e(initialValue: 0);\n\tset =\u003e this.Set(value);\n}\n```\n- Write and execute `ckpropvg` to create a one-way DynamicProperty from a value.\n```cs\npublic int MyProperty =\u003e this.Get\u003cint\u003e(initialValue: 0);\n```\n\n### DynamicCommand\nOn projects that uses [Chinook.DynamicMvvm](https://github.com/nventive/Chinook.DynamicMvvm), there are a couple of snippets available for creating commands. Writing `ckcmd` will display all the available snippets. ![image](/doc/images/ckcmd.png)\n\n\n#### From Action\n- Write and execute `ckcmda` to create a `IDynamicCommand` from an `Action`.\n```cs\npublic IDynamicCommand MyCommand =\u003e this.GetCommand(() =\u003e\n\t{\n\n\t});\n```\n- Write and execute `ckcmdap` to create a `IDynamicCommand` from an `Action`. with a parameter.\n```cs\npublic IDynamicCommand MyCommand =\u003e this.GetCommand\u003cint\u003e(parameter =\u003e\n\t{\n\n\t});\n```\n\n#### From Task\n- Write and execute `ckcmdt` to create a `IDynamicCommand` from a `Task`.\n```cs\npublic IDynamicCommand MyCommand =\u003e this.GetCommandFromTask(async ct =\u003e\n\t{\n\n\t});\n```\n- Write and execute `ckcmdtp` to create a `IDynamicCommand` from a `Task`. with a parameter.\n```cs\npublic IDynamicCommand MyCommand =\u003e this.GetCommandFromTask\u003cint\u003e(async (ct, parameter) =\u003e\n\t{\n\n\t});\n```\n\n### DataLoader\nOn projects that uses [Chinook.DataLoader](https://github.com/nventive/Chinook.DataLoader), you can use the following snippet to create dataloaders:\n\n- Write and execute `ckdl` to create a `IDataLoader`.\n```cs\npublic IDataLoader\u003cint\u003e MyDataLoader =\u003e this.GetDataLoader(LoadMyDataLoader);\n\nprivate async Task\u003cint\u003e LoadMyDataLoader(CancellationToken ct, IDataLoaderRequest request)\n{\n\treturn default(int);\n}\n```\n- Write and execute `ckdlv` to create a `DataLoaderViewState` for x:Bind (Chinook.DataLoader.WinUI only)\n```cs\npublic class DataLoaderViewState_int : DataLoaderViewState\n{\n\tpublic DataLoaderViewState_int(DataLoaderViewState dataLoaderViewState) : base(dataLoaderViewState)\n\t{\n\t\tData = (int)dataLoaderViewState.Data;\n\t}\n\n\tpublic new int Data { get; }\n}\n\npublic class DataLoaderView_int : DataLoaderView\n{\n\tpublic DataLoaderView_int()\n\t{\n\t\tStyle = App.Current.Resources[typeof(DataLoaderView)] as Style;\n\t}\n\n\tprotected override void SetState(DataLoaderViewState state)\n\t{\n\t\tvar typedState = new DataLoaderViewState_int(state);\n\t\tbase.SetState(typedState);\n\t}\n}\n```\n- Write and execute `ckdlvx` to add a `DataLoaderView` (Chinook.DataLoader.WinUI only)\n```xaml\n\u003clocal:DataLoaderView_int Source = \"{x:Bind DataLoader}\" \u003e\n  \u003cDataTemplate x:DataType=\"local:DataLoaderViewState_int\"\u003e\n  \u003c/DataTemplate\u003e\n\u003c/local:DataLoaderView_int\u003e\n```\n\n## Breaking changes\n\nPlease consult [BREAKING_CHANGES.md](BREAKING_CHANGES.md) for more information about version\nhistory and compatibility.\n\n## License\n\nThis project is licensed under the Apache 2.0 license - see the\n[LICENSE](LICENSE) file for details.\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for\ncontributing to this project.\n\nBe mindful of our [Code of Conduct](CODE_OF_CONDUCT.md).\n\nMake sure you read [this guide](https://docs.microsoft.com/en-us/visualstudio/ide/how-to-distribute-code-snippets) on how to distribute code snippets.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnventive%2Fchinooksnippets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnventive%2Fchinooksnippets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnventive%2Fchinooksnippets/lists"}