Exemple #1
0
        public void Configure(Type concreteComponent, DependencyLifecycle dependencyLifecycle)
        {
            ConfigureComponentAdapter config =
                container.ResolveAll <ConfigureComponentAdapter>().Where(x => x.ConfiguredType == concreteComponent).
                FirstOrDefault();

            if (config == null)
            {
                IEnumerable <Type> interfaces = GetAllServiceTypesFor(concreteComponent);
                config = new ConfigureComponentAdapter(container, concreteComponent);
                container.RegisterInstance(Guid.NewGuid().ToString(), config);

                foreach (Type t in interfaces)
                {
                    if (typesWithDefaultInstances.Contains(t))
                    {
                        container.RegisterType(t, concreteComponent, Guid.NewGuid().ToString(), GetLifetimeManager(dependencyLifecycle));
                    }
                    else
                    {
                        container.RegisterType(t, concreteComponent, GetLifetimeManager(dependencyLifecycle));
                        typesWithDefaultInstances.Add(t);
                    }
                }
            }
        }
        public void Configure(Type concreteComponent, ComponentCallModelEnum callModel)
        {
            ConfigureComponentAdapter config =
               container.ResolveAll<ConfigureComponentAdapter>().Where(x => x.ConfiguredType == concreteComponent).
                  FirstOrDefault();
            if (config == null)
            {
                IEnumerable<Type> interfaces = GetAllServiceTypesFor(concreteComponent);
                config = new ConfigureComponentAdapter(container, concreteComponent);
                container.RegisterInstance(Guid.NewGuid().ToString(), config);

                foreach (Type t in interfaces)
                {
                    if (typesWithDefaultInstances.Contains(t))
                    {
                        container.RegisterType(t, concreteComponent, Guid.NewGuid().ToString(), GetLifetimeManager(callModel));
                    }
                    else
                    {
                        container.RegisterType(t, concreteComponent, GetLifetimeManager(callModel));
                        typesWithDefaultInstances.Add(t);
                    }
                }
            }
        }
Exemple #3
0
        public void ConfigureProperty(Type concreteComponent, string property, object value)
        {
            ConfigureComponentAdapter config =
                container.ResolveAll <ConfigureComponentAdapter>().Where(x => x.ConfiguredType == concreteComponent).
                First();

            config.ConfigureProperty(property, value);
        }