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 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)); }