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); }
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; }
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); }
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); }