/// <summary> /// 设定配置的值 /// </summary> /// <typeparam name="T">值的类型</typeparam> /// <param name="name">配置名</param> /// <param name="value">配置的值</param> public void Set <T>(string name, T value) { Guard.NotNull(name, "name"); if (locators.Count <= 0) { throw new RuntimeException("No Reg locator. please Reg() locator first."); } IConfigLocator configLocator = null; string val; foreach (var locator in locators) { if (locator.TryGetValue(name, out val)) { configLocator = locator; } } if (configLocator == null) { configLocator = locators.Last(); } ITypeStringConverter converter; if (!typeStringConverters.TryGetValue(typeof(T), out converter)) { throw new ConverterException("Can not find [" + typeof(T) + "] coverter impl."); } configLocator.Set(name, converter.ConvertToString(value)); }
public void FirstLastTest() { var master = new SortSet <int, int>(0.25, 32); for (var i = 0; i < 65536; i++) { master.Add(i, i); } Assert.AreEqual(0, master.First()); Assert.AreEqual(65535, master.Last()); for (var i = 0; i < 65536; i++) { Assert.AreEqual(i, master.First()); Assert.AreEqual(i, master.Shift()); } Assert.AreEqual(0, master.Count); master = new SortSet <int, int>(0.25, 32); for (var i = 0; i < 65536; i++) { master.Add(i, i); } for (var i = 0; i < 65536; i++) { Assert.AreEqual(65535 - i, master.Last()); Assert.AreEqual(65535 - i, master.Pop()); } }
public void LastEmptySortSet() { var master = new SortSet <int, int>(0.25, 32); ExceptionAssert.Throws <InvalidOperationException>(() => { master.Last(); }); }
public void BoundLastTest() { var master = new SortSet <int, int>(0.25, 32); ExceptionAssert.DoesNotThrow(() => { master.Last(); }); }