Exemple #1
0
        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));
        }
Exemple #2
0
 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");
        }