Example #1
0
        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());
        }
Example #2
0
 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>();
 }
Example #3
0
 public bool TryGet(string name, out IConfigurationScope scope)
 {
     return(storage.TryGetValue(name, out scope));
 }
Example #4
0
 public void MapScope(string name, IConfigurationScope scope)
 {
     Ensure.NotNull(name, "name");
     Ensure.NotNull(scope, "scope");
     storage[name] = scope;
 }