Exemple #1
0
        private static void InternalRegister(IServiceRegistry kernel, ComponentExpression component)
        {
            if (component.Implementation == null && component.Factory == null)
            {
                throw new ArgumentNullException("Implementation == null && Factory ==null");
            }

            if (string.IsNullOrEmpty(component.Id))
            {
                if (component.Implementation != null)
                {
                    component.Id = component.Implementation.FullName;
                }
                else
                {
                    component.Id = component.Factory.ToString() + "/" + component.Contracts[0].FullName;
                }
            }

            if (component.Implementation != null && component.Implementation.IsOpenGenericType())
            {
                component.Lifestyle = LifestyleType.GetGenericLifestyle(component.Lifestyle);
            }

            kernel.Register(component);
        }
Exemple #2
0
        public static IServiceRegistry Register(this IServiceRegistry kernel, Action<IComponentExpression> handler)
        {
            Guard.NotNull(kernel, "kernel");
            Guard.NotNull(handler, "handler");
          
            var component = new ComponentExpression { Registry = kernel };
            handler(component);

            InternalRegister(kernel, component);

            return kernel;
        }
Exemple #3
0
        public static IServiceRegistry Register(this IServiceRegistry kernel, Action <IComponentExpression> handler)
        {
            Guard.NotNull(kernel, "kernel");
            Guard.NotNull(handler, "handler");

            var component = new ComponentExpression {
                Registry = kernel
            };

            handler(component);

            InternalRegister(kernel, component);

            return(kernel);
        }
Exemple #4
0
        private static void InternalRegister(IServiceRegistry kernel, ComponentExpression component)
        {
            if (component.Implementation == null && component.Factory == null)
                throw new ArgumentNullException("Implementation == null && Factory ==null");

            if (string.IsNullOrEmpty(component.Id))
            {
                if (component.Implementation != null)
                    component.Id = component.Implementation.FullName;
                else
                    component.Id = component.Factory.ToString() + "/" + component.Contracts[0].FullName;
            }

            if (component.Implementation != null && component.Implementation.IsOpenGenericType())
                component.Lifestyle = LifestyleType.GetGenericLifestyle(component.Lifestyle);

            kernel.Register(component);
        }