public void ImportSettingsShouldUpdateAndFireEvent() { int firedCount = 0; var settings = new SettingsContainer(string.Empty); settings.ValueChanged += (s, e) => firedCount++; settings.SetValue("A", "A"); settings.SetValue("B", 1); settings.SetValue("C", true); firedCount.ShouldBeEquivalentTo(3); var importSource = new JsonObject(); importSource.SetNamedString("A", "x"); importSource.SetNamedNumber("B", 2); importSource.SetNamedBoolean("C", true); settings.Import(importSource); firedCount.ShouldBeEquivalentTo(5); settings.GetString("A").ShouldBeEquivalentTo("x"); settings.GetInteger("B").ShouldBeEquivalentTo(2); settings.GetBoolean("C").ShouldBeEquivalentTo(true); }
public void SetAndRead_Settings() { var settings = new SettingsContainer(string.Empty); settings.SetValue("A", "A"); settings.SetValue("B", 1); settings.SetValue("C", true); settings.SetValue("D", TimeSpan.Parse("12:30")); settings.SetValue("E", 1.1F); settings.GetString("A").ShouldBeEquivalentTo("A"); settings.GetInteger("B").ShouldBeEquivalentTo(1); settings.GetBoolean("C").ShouldBeEquivalentTo(true); settings.GetTimeSpan("D").ShouldBeEquivalentTo(TimeSpan.Parse("12:30")); settings.GetFloat("E").ShouldBeEquivalentTo(1.1F); }
public static void UsingContainer(SettingsContainer <RepoDistSettings, GitExtSettingsCache> aSettingsContainer, Action action) { SettingsContainer.LockedAction(() => { var oldSC = SettingsContainer; try { _SettingsContainer = aSettingsContainer; action(); } finally { _SettingsContainer = oldSC; //refresh settings if needed SettingsContainer.GetString(string.Empty, null); } } ); }
public static string GetString(string name, string defaultValue) { return(SettingsContainer.GetString(name, defaultValue)); }