public DependencyProvider(DependenciesConfiguration configuration)
 {
     if (ValidateConfiguration(configuration))
     {
         this._configuration = configuration;
         _stack = new ConcurrentStack <Type>();
     }
 }
 private bool ValidateConfiguration(DependenciesConfiguration dependenciesConfiguration)
 {
     foreach (Type dependences in dependenciesConfiguration.DependencesList.Keys)
     {
         if (dependences.IsValueType)
         {
             throw new ArgumentException("Config is not valid");
         }
     }
     return(true);
 }
示例#3
0
 public DependencyProvider(DependenciesConfiguration config, bool singletonPolicy = false)
 {
     isSingleton      = singletonPolicy;
     singletonObjects = new ConcurrentDictionary <Type, object>();
     dependencies     = new Dictionary <Type, List <Type> >();
     foreach (var dependency in config.GetContent())
     {
         Type dep  = dependency.Key;
         var  list = new List <Type>();
         foreach (var impl in dependency.Value)
         {
             if ((dep.IsAssignableFrom(impl) && !impl.IsAbstract && !impl.IsInterface) || (dep.IsGenericTypeDefinition))
             {
                 list.Add(impl);
             }
         }
         if (list.Count != 0)
         {
             dependencies.Add(dep, list);
         }
     }
 }
示例#4
0
 public DependencyProvider(DependenciesConfiguration dependencies)
 {
     this.dependencies = dependencies;
 }
示例#5
0
 public DependencyProvider(DependenciesConfiguration configuration)
 {
     _configuration     = configuration;
     _locker            = new object();
     _typesInGeneration = new List <Type>();
 }