Пример #1
0
        public static ComponentRegistration FactoryMethod(this ComponentRegistration reg, IKernel kernel, Type type, Func <object> factory)
        {
            Type item        = typeof(InternalFactory <>).MakeGenericType(type);
            var  factoryName = item.FullName;

            kernel.Register(Component.For(item).Named(factoryName).Instance(new GenericFactory(factory)).LifeStyle.Transient.OnlyNewServices());
            reg.Configuration(Attrib.ForName("factoryId").Eq(factoryName), Attrib.ForName("factoryCreate").Eq("Create"));
            return(reg);
        }