Giter Site home page Giter Site logo

chinooksnippets's Introduction

Chinook Snippets

VisualStudio Extension providing code snippets for Chinook libraries.

License

Getting Started

  1. Install the Chinook Snippets Visual Studio Extension

  2. 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.
    image image

Features

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.

DynamicProperty

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. image

From Observable

  • 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();
}

From Task

  • Write and execute ckpropt to create a two-way DynamicProperty from a Task.
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 a Task.
public int MyProperty => this.GetFromTask<int>(GetMyProperty, initialValue: 0);

private async Task<int> GetMyProperty(CancellationToken ct)
{
	throw new NotImplementedException();
}

From Value

  • 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);

DynamicCommand

On projects that uses Chinook.DynamicMvvm, there are a couple of snippets available for creating commands. Writing ckcmd will display all the available snippets. image

From Action

  • Write and execute ckcmda to create a IDynamicCommand from an Action.
public IDynamicCommand MyCommand => this.GetCommand(() =>
	{

	});
  • Write and execute ckcmdap to create a IDynamicCommand from an Action. with a parameter.
public IDynamicCommand MyCommand => this.GetCommand<int>(parameter =>
	{

	});

From Task

  • Write and execute ckcmdt to create a IDynamicCommand from a Task.
public IDynamicCommand MyCommand => this.GetCommandFromTask(async ct =>
	{

	});
  • Write and execute ckcmdtp to create a IDynamicCommand from a Task. with a parameter.
public IDynamicCommand MyCommand => this.GetCommandFromTask<int>(async (ct, parameter) =>
	{

	});

DataLoader

On projects that uses Chinook.DataLoader, you can use the following snippet to create dataloaders:

  • Write and execute ckdl to create a IDataLoader.
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 a DataLoaderViewState 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 a DataLoaderView (Chinook.DataLoader.WinUI only)
<local:DataLoaderView_int Source = "{x:Bind DataLoader}" >
  <DataTemplate x:DataType="local:DataLoaderViewState_int">
  </DataTemplate>
</local:DataLoaderView_int>

Breaking changes

Please consult BREAKING_CHANGES.md for more information about version history and compatibility.

License

This project is licensed under the Apache 2.0 license - see the LICENSE file for details.

Contributing

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.

chinooksnippets's People

Contributors

jeanplevesque avatar takla21 avatar guidemarcus avatar matfillion avatar

Watchers

James Cloos avatar Romaric Fabre avatar Francis Desjardins avatar Guillaume Fortin avatar Jean-Philippe Lavoie avatar Carl de Billy avatar David avatar Gabriel Létourneau avatar Silviu Obreja avatar guerinyohan@gmail.com avatar Félix Perreault avatar Frédérick Gibeau avatar  avatar  avatar Geoffrey Fielden-Briggs avatar Charles Héon avatar Alex Trépanier avatar

chinooksnippets's Issues

Dependabot couldn't find a <anything>.(cs|vb|fs)proj for this project

Dependabot couldn't find a .(cs|vb|fs)proj for this project.

Dependabot requires a .(cs|vb|fs)proj to evaluate your project's current .NET dependencies. It had expected to find one at the path: /<anything>.(cs|vb|fs)proj.

If this isn't a .NET project, or if it is a library, you may wish to disable updates for it in the .dependabot/config.yml file in this repo.

View the update logs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.