public ConfigurationRegistry Apply(TypesList typesList, Action<ContainerConfigurationBuilder> modificator)
 {
     if (modificator == null)
         return this;
     var builder = new ContainerConfigurationBuilder();
     modificator(builder);
     return builder.RegistryBuilder.Build(typesList, this);
 }
Exemplo n.º 2
0
 public SimpleContainer(GenericsAutoCloser genericsAutoCloser, ConfigurationRegistry configurationRegistry,
     TypesList typesList, LogError errorLogger, LogInfo infoLogger,
     Dictionary<Type, Func<object, string>> valueFormatters)
 {
     Configuration = configurationRegistry;
     implementationSelectors = configurationRegistry.GetImplementationSelectors();
     this.genericsAutoCloser = genericsAutoCloser;
     this.typesList = typesList;
     dependenciesInjector = new DependenciesInjector(this);
     this.errorLogger = errorLogger;
     containerContext = new ContainerContext
     {
         infoLogger = infoLogger,
         typesList = typesList,
         valueFormatters = valueFormatters
     };
 }
 private void ApplyDynamicConfigurators(TypesList typesList)
 {
     var configurationSet = new ServiceConfigurationSet();
     var builder = new ServiceConfigurationBuilder<object>(configurationSet);
     foreach (var c in dynamicConfigurators)
     {
         var targetTypes = c.BaseType == null ? typesList.Types.ToList() : typesList.InheritorsOf(c.BaseType);
         foreach (var t in targetTypes)
         {
             if (configurations.ContainsKey(t))
                 continue;
             try
             {
                 c.ConfigureAction(t, builder);
             }
             catch (Exception e)
             {
                 const string messageFormat = "exception invoking [{0}] for [{1}]";
                 throw new SimpleContainerException(string.Format(messageFormat, c.Description, t.FormatName()), e);
             }
             if (configurationSet.IsEmpty())
                 continue;
             if (!string.IsNullOrEmpty(c.Description))
                 configurationSet.SetDefaultComment(c.Description);
             configurations.Add(t, configurationSet);
             configurationSet = new ServiceConfigurationSet();
             builder = new ServiceConfigurationBuilder<object>(configurationSet);
         }
     }
 }
 public ConfigurationRegistry Build(TypesList typesList, ConfigurationRegistry parent)
 {
     ApplyDynamicConfigurators(typesList);
     IConfigurationSource configurationSource = new SimpleConfigurationSource(configurations);
     if (parent != null)
     {
         foreach (var p in parent.contractUnions)
             if (!contractUnions.ContainsKey(p.Key))
                 contractUnions.Add(p);
         implementationSelectors.AddRange(parent.implementationSelectors);
         configurationSource = new MergingConfigurationSource(configurationSource, parent.configurations);
     }
     return new ConfigurationRegistry(configurationSource, contractUnions, implementationSelectors);
 }
Exemplo n.º 5
0
 public GenericsAutoCloser(TypesList typesList, Func <AssemblyName, bool> assemblyFilter)
 {
     this.typesList      = typesList;
     this.assemblyFilter = assemblyFilter;
 }
 public GenericsAutoCloser(TypesList typesList, Func<AssemblyName, bool> assemblyFilter)
 {
     this.typesList = typesList;
     this.assemblyFilter = assemblyFilter;
 }