internal ConfigurationCollection(IConfigurationValueCollection defaults) { this.Descriptor = ConfigurationDescriptorCache.GetCollectionDescriptor <T>(); this.collectionInterceptor = new CollectionInterceptor <T>(defaults); this.Configuration = ConfigurationDescriptorCache .GetProxyGenerator().CreateInterfaceProxyWithoutTarget <T> (new CollectionCircularInterceptor <T>(this), this.collectionInterceptor); this.ValueCollection = defaults; }
internal ConfigurationSection(IConfigurationValueCollection values, string sectionKey) { this.Descriptor = new ConfigurationSectionDescriptor <T>(sectionKey); this.configurationInterceptor = new ConfigurationInterceptor(this.Descriptor, values); // if this is a CVC base implementation, we should ensure defaults. (values as ConfigurationValueCollection)?.EnsureSectionDefaults(this.Descriptor); this.ValueCollection = values; this.Configuration = ConfigurationDescriptorCache .GetProxyGenerator() .CreateInterfaceProxyWithoutTarget <T>(new ConfigurationCircularInterceptor <T>(this), configurationInterceptor); }
internal ConfigurationCollection(IConfigurationValueCollection defaults) { this.Descriptor = ConfigurationDescriptorCache.GetCollectionDescriptor <T>(); var genInstance = typeof(T).GetCustomAttribute <ConfigurationGenerationInstanceAttribute>(); if (genInstance == null) { throw new InvalidOperationException("Not generated!"); // todo: mark with interface to fail at compile time. } this.ValueCollection = defaults; this.Configuration = (T)Instantiate.CreateInstance(genInstance.InstanceType, new[] { typeof(IConfigurationValueCollection) }, Expression.Constant(this.ValueCollection)); }