public static IDisposable Use([NotNull] this IContextProperties properties, [NotNull] string name, [CanBeNull] object value) { var oldValueExisted = properties.Current.TryGetValue(name, out var oldValue); properties.Set(name, value); return(new ContextPropertyScope(properties, name, oldValue, oldValueExisted)); }
public void Dispose() { if (oldValueExisted) { properties.Set(key, oldValue); } else { properties.Remove(key); } }
public void Get_should_return_default_value_when_property_value_has_unexpected_type() { properties.Set("name", new object()); properties.Get("name", "default").Should().Be("default"); }