VisualStudio Extension providing code snippets for Chinook libraries.
-
Install the
Chinook Snippets
Visual Studio Extension- Download the
.vsix
directly from the Visual Studio Marketplace - Chinook Snippets. - Install it directly in Visual Studio
- Download the
-
Start writing
ck
and a list of snippets will appear. Choose any of the available Chinook snippets and press theTAB
key to execute the snippet.
Explore 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.
On projects that uses Chinook.DynamicMvvm, there are a couple of snippets available for creating dynamic properties. Writing ckprop
will display all the available snippets.
- Write and execute
ckpropo
to create a two-way DynamicProperty from an observable.
public int MyProperty
{
get => this.GetFromObservable<int>(ObserveMyProperty(), initialValue: 0);
set => this.Set(value);
}
private IObservable<int> ObserveMyProperty()
{
throw new NotImplementedException();
}
- Write and execute
ckpropog
to create a one-way DynamicProperty from an observable.
public int MyProperty => this.GetFromObservable<int>(ObserveMyProperty(), initialValue: 0);
private IObservable<int> ObserveMyProperty()
{
throw new NotImplementedException();
}
- Write and execute
ckpropt
to create a two-way DynamicProperty from aTask
.
public int MyProperty
{
get => this.GetFromTask<int>(GetMyProperty, initialValue: 0);
set => this.Set(value);
}
private async Task<int> GetMyProperty(CancellationToken ct)
{
throw new NotImplementedException();
}
- Write and execute
ckproptg
to create a one-way DynamicProperty from aTask
.
public int MyProperty => this.GetFromTask<int>(GetMyProperty, initialValue: 0);
private async Task<int> GetMyProperty(CancellationToken ct)
{
throw new NotImplementedException();
}
- Write and execute
ckpropv
to create a two-way DynamicProperty from a value.
public int MyProperty
{
get => this.Get<int>(initialValue: 0);
set => this.Set(value);
}
- Write and execute
ckpropvg
to create a one-way DynamicProperty from a value.
public int MyProperty => this.Get<int>(initialValue: 0);
On projects that uses Chinook.DynamicMvvm, there are a couple of snippets available for creating commands. Writing ckcmd
will display all the available snippets.
- Write and execute
ckcmda
to create aIDynamicCommand
from anAction
.
public IDynamicCommand MyCommand => this.GetCommand(() =>
{
});
- Write and execute
ckcmdap
to create aIDynamicCommand
from anAction
. with a parameter.
public IDynamicCommand MyCommand => this.GetCommand<int>(parameter =>
{
});
- Write and execute
ckcmdt
to create aIDynamicCommand
from aTask
.
public IDynamicCommand MyCommand => this.GetCommandFromTask(async ct =>
{
});
- Write and execute
ckcmdtp
to create aIDynamicCommand
from aTask
. with a parameter.
public IDynamicCommand MyCommand => this.GetCommandFromTask<int>(async (ct, parameter) =>
{
});
On projects that uses Chinook.DataLoader, you can use the following snippet to create dataloaders:
- Write and execute
ckdl
to create aIDataLoader
.
public IDataLoader<int> MyDataLoader => this.GetDataLoader(LoadMyDataLoader);
private async Task<int> LoadMyDataLoader(CancellationToken ct, IDataLoaderRequest request)
{
return default(int);
}
- Write and execute
ckdlv
to create aDataLoaderViewState
for x:Bind (Chinook.DataLoader.WinUI only)
public class DataLoaderViewState_int : DataLoaderViewState
{
public DataLoaderViewState_int(DataLoaderViewState dataLoaderViewState) : base(dataLoaderViewState)
{
Data = (int)dataLoaderViewState.Data;
}
public new int Data { get; }
}
public class DataLoaderView_int : DataLoaderView
{
public DataLoaderView_int()
{
Style = App.Current.Resources[typeof(DataLoaderView)] as Style;
}
protected override void SetState(DataLoaderViewState state)
{
var typedState = new DataLoaderViewState_int(state);
base.SetState(typedState);
}
}
- Write and execute
ckdlvx
to add aDataLoaderView
(Chinook.DataLoader.WinUI only)
<local:DataLoaderView_int Source = "{x:Bind DataLoader}" >
<DataTemplate x:DataType="local:DataLoaderViewState_int">
</DataTemplate>
</local:DataLoaderView_int>
Please consult BREAKING_CHANGES.md for more information about version history and compatibility.
This project is licensed under the Apache 2.0 license - see the LICENSE file for details.
Please read CONTRIBUTING.md for details on the process for contributing to this project.
Be mindful of our Code of Conduct.
Make sure you read this guide on how to distribute code snippets.