public static Expression GenExpression(this InjectionMember injectionMember, Type registrationType, IQuickInjectContainer container) { var injectionMemberType = injectionMember.GetType(); var baseType = injectionMemberType.GetTypeInfo().BaseType; if (baseType == typeof(InjectionMember)) { return(new ParameterizedLambdaExpressionInjectionFactoryMethodCallExpression(injectionMember.Factory)); } throw new Exception("Unknown registration factory"); }
public IQuickInjectContainer RegisterType(Type from, Type to, LifetimeManager lifetimeManager, InjectionMember injectionMember = null) { if (to == null) { throw new ArgumentNullException("to"); } if ((from != null && from.GetTypeInfo().IsGenericTypeDefinition) || to.GetTypeInfo().IsGenericTypeDefinition) { throw new ArgumentException("Open Generic Types are not supported"); } this.Registering(this, new RegisterEventArgs(from, to, lifetimeManager)); lock (this.lockObj) { if (from != null) { this.typeMappingTable.AddOrUpdate(from, to); } if (lifetimeManager != null) { this.lifetimeTable.AddOrUpdate(to, lifetimeManager); } if (injectionMember != null) { this.factoryExpressionTable.AddOrUpdate(to, injectionMember.GenExpression(to, this)); } this.ClearBuildPlans(); } return(this); }
public static IQuickInjectContainer RegisterType <T>(this IQuickInjectContainer container, InjectionMember injectionMember = null) { return(container.RegisterType(null, typeof(T), null, injectionMember)); }
public static IQuickInjectContainer RegisterType(this IQuickInjectContainer container, Type t, LifetimeManager lifetimeManager, InjectionMember injectionMember = null) { return(container.RegisterType(null, t, lifetimeManager, injectionMember)); }
public static IQuickInjectContainer RegisterType(this IQuickInjectContainer container, Type from, Type to, InjectionMember injectionMember = null) { return(container.RegisterType(from, to, null, injectionMember)); }
public static IQuickInjectContainer RegisterType <TFrom, TTo>(this IQuickInjectContainer container, LifetimeManager lifetimeManager, InjectionMember injectionMember = null) where TTo : TFrom { return(container.RegisterType(typeof(TFrom), typeof(TTo), lifetimeManager, injectionMember)); }