public T GetProperty <T>() where T : IConfigurationProperty, new() { if (properties.Contains(typeof(T))) { IConfigurationProperty property = new T(); IUpdateableConfigurationProperty updateable = property as IUpdateableConfigurationProperty; if (updateable != null) { IConfigurationScope scope = null; if (property.ScopeName == null || !scopeRegistry.TryGet(property.ScopeName, out scope)) { scope = defaultScope; } IConfigurationStorage storage = scope.GetStorage(); string propertyValue; if (storage.TryGetValue(property.Name, out propertyValue)) { updateable.SetValue(propertyValue); } } return((T)property); } return(new T()); }
public ConfigurationBase(IConfigurationScopeRegistry scopeRegistry, IConfigurationScope defaultScope) { Ensure.NotNull(scopeRegistry, "scopeRegistry"); Ensure.NotNull(defaultScope, "defaultScope"); this.scopeRegistry = scopeRegistry; this.defaultScope = defaultScope; this.properties = new HashSet <Type>(); }
public bool TryGet(string name, out IConfigurationScope scope) { return(storage.TryGetValue(name, out scope)); }
public void MapScope(string name, IConfigurationScope scope) { Ensure.NotNull(name, "name"); Ensure.NotNull(scope, "scope"); storage[name] = scope; }