Exemple #1
0
        public ISupplyPlugin <TPlugin> For <TPlugin>(string name)
        {
            var expression = DependencyExpression.For <TPlugin>(name);

            Dependencies.Add(expression);
            return(expression);
        }
Exemple #2
0
        public ISupplyPlugin <object> For(string name, Type pluginType)
        {
            var expression = DependencyExpression.For(name, pluginType);

            Dependencies.Add(expression);
            return(expression);
        }
Exemple #3
0
        protected void RegisterClosingType(Type type, Type match, IDependencyRegistry registry)
        {
            var name = HasNamingStrategy ? NamingStrategy(type) : string.Empty;
            var dependencyExpression = HasNamingStrategy
                                      ? DependencyExpression.For(name, type)
                                      : DependencyExpression.For(type);

            dependencyExpression.Use(match);
            registry.Register(dependencyExpression);
        }
Exemple #4
0
 protected void RegisterSingleImplementations(IDependencyRegistry registry)
 {
     Assimilate
     .ScanIndex
     .SingleImplementations
     .Where(x => x.Value.IsConcrete())
     .ForEach(x =>
     {
         var dependencyExpression = DependencyExpression.For(x.Key);
         dependencyExpression.Use(x.Value);
         registry.Register(dependencyExpression);
     });
 }
Exemple #5
0
        protected void RegisterTypeClosingInterface(Type type, Type match, IDependencyRegistry registry)
        {
            match.GetInterfaces()
            .Where(x => x.IsGenericType && x.GetGenericTypeDefinition().Equals(type))
            .ForEach(x =>
            {
                var pluginType = type.MakeGenericType(x.GetGenericArguments());

                var name = HasNamingStrategy ? NamingStrategy(type) : string.Empty;
                var dependencyExpression = HasNamingStrategy
                                                ? DependencyExpression.For(name, pluginType)
                                                : DependencyExpression.For(pluginType);
                dependencyExpression.Add(match);
                registry.Register(dependencyExpression);
            });
        }
Exemple #6
0
        protected void RegisterAllTypesOf(Type type, IDependencyRegistry registry)
        {
            var list = Assimilate.ScanIndex.ImplementorsOfType.TryGet(type);

            if (list.Item1)
            {
                list.Item2
                .Where(x => x.IsConcrete())
                .Where(x => x.GetGenericCardinality() == type.GetGenericCardinality())
                .ForEach(m =>
                {
                    var name = HasNamingStrategy ? NamingStrategy(m) : string.Empty;
                    var dependencyExpression = HasNamingStrategy
                                          ? DependencyExpression.For(name, type)
                                          : DependencyExpression.For(type);
                    dependencyExpression.Add(m);
                    registry.Register(dependencyExpression);
                });
            }
        }