Skip to content

Latest commit

 

History

History
134 lines (99 loc) · 4.13 KB

README.md

File metadata and controls

134 lines (99 loc) · 4.13 KB

SavableConfig

Can two bind way configuration

Nuget Codacy Badge FOSSA Status codecov

Build Status

Provider Status
Github .NET
Azure Pipelines Build Status

What it is

It can two way bind configuration.

The MS configurations provider File -> Map way.

The project support Map changed -> File way.

  • It support configuration dynamic proxy.
  • It can use data binding at wpf, xamarin, avaloniaui...
  • It can auto save, when the configuration is changed!
  • It can auto proxy your profile class, modify property auto modify configuration.

Why it can do that

Can reversal store is i modify the MS configuration lib to make it support, and proxy use MS IL to dynamic create proxy class.

How to use it

The NameTransfer is very import to provider find configuration path!

You can use auto proxy

You can watch sample\TwoWayBind

Or wpf project sample\TwoWayBindWpf use in wpf binding

var builder = new ConfigurationBuilder();
builder.AddJsonFile("appsettings.json", false, true);
//Make configuration
var root = builder.BuildSavable();
//Create proxy and create proxy object
var value = root.AutoCreateProxy<DbConnection>();
root.BindTwoWay(value, JsonChangeTransferCondition.Instance);

You can use observable object

You can watch sample\TwoWayBindWpf

ThemeService.cs

public class ThemeService : ObservableObject
{
	private string title;
	private WindowStyle windowStyle;
	private bool buttonEnable;
	private int age;
	private ButtonStyle buttonStyle;

	public int Age
	{
		get => age;
		set => Set(ref age, value);
	}

	public virtual bool ButtonEnable
	{
		get { return buttonEnable; }
		set => Set(ref buttonEnable, value);
	}

	public WindowStyle WindowStyle
	{
		get { return windowStyle; }
		set => Set(ref windowStyle, value);
	}


	public string Title
	{
		get { return title; }
		set => Set(ref title, value);
	}

	public ButtonStyle ButtonStyle
	{
		get => buttonStyle;
		set => Set(ref buttonStyle, value);
	}
}
var inst = new ThemeService();
var box=root.BindNotifyTwoWay(inst, JsonChangeTransferCondition.Instance);

//If you want detch binding, you can
box.Dispose();

When you change CLR properties or config, it will two way binding also!

Features

  • Add unit test, to conver nearly 100% codes
  • To make easy use it
  • Add object <-> string converter like wpf IValueConverter
  • Add more provider transfer (Now only json)
  • Add xamarin/MAUI, avaloniaui... samples
  • Make it base on MS configuration instead of overwrite it(Break change)

Nuget

License

FOSSA Status