/// <summary> /// Alias for RegisterAutoWiredAs /// </summary> /// <typeparam name="T"></typeparam> public void RegisterAs <T, TAs>() where T : TAs { var autoWired = new ExpressionTypeFunqContainer(this); autoWired.RegisterAs <T, TAs>(); }
public static ITypeFactory GetAutoWiredFunqTypeFactory() { var container = GetContainerWithDependencies(); var typeFactory = new ExpressionTypeFunqContainer(container); typeFactory.RegisterTypes(typeof(StoreCustomersService), typeof(GetCustomerService)); return typeFactory; }
public static ITypeFactory GetAutoWiredFunqTypeFactory() { var container = GetContainerWithDependencies(); var typeFactory = new ExpressionTypeFunqContainer(container); typeFactory.RegisterTypes(typeof(StoreCustomersService), typeof(GetCustomerService)); return(typeFactory); }
public void Init() { this.Container = new Container(); var typeFactory = new ExpressionTypeFunqContainer(this.Container); this.ServiceController.Register(typeFactory, assembliesWithServices); typeFactory.RegisterTypes(this.ServiceController.ServiceTypes); }
public void With_Funq_and_Expressions() { var container = new Container(); container.Register<IFoo>(c => new Foo()); container.Register<IBar>(c => new Bar()); var funqlet = new ExpressionTypeFunqContainer(container); funqlet.RegisterTypes(typeof(AutoWireService)); Console.WriteLine("With_Funq_and_Expressions(): {0}", Measure(() => container.Resolve<AutoWireService>(), Times)); }
/// <summary> /// Auto-scans the provided assemblies for a <see cref="IValidator"/> /// and registers it in the provided IoC container. /// </summary> /// <param name="container">The IoC container</param> /// <param name="assemblies">The assemblies to scan for a validator</param> public static void RegisterValidators(this Container container, params Assembly[] assemblies) { var autoWire = new ExpressionTypeFunqContainer(container); foreach (var assembly in assemblies) { foreach (var validator in assembly.GetTypes() .Where(t => t.IsOrHasGenericInterfaceTypeOf(typeof(IValidator<>)))) { RegisterValidator(autoWire, validator); } } }
public void With_Funq_and_Expressions() { var container = new Container(); container.Register <IFoo>(c => new Foo()); container.Register <IBar>(c => new Bar()); var funqlet = new ExpressionTypeFunqContainer(container); funqlet.RegisterTypes(typeof(AutoWireService)); Console.WriteLine("With_Funq_and_Expressions(): {0}", Measure(() => container.Resolve <AutoWireService>(), Times)); }
private static void RegisterValidator(ExpressionTypeFunqContainer autoWire, Type validator) { var baseType = validator.BaseType; while (!baseType.IsGenericType) { baseType = baseType.BaseType; } var dtoType = baseType.GetGenericArguments()[0]; var validatorType = typeof (IValidator<>).MakeGenericType(dtoType); autoWire.RegisterType(validator, validatorType); }
/// <summary> /// Auto-scans the provided assemblies for a <see cref="IValidator"/> /// and registers it in the provided IoC container. /// </summary> /// <param name="container">The IoC container</param> /// <param name="assemblies">The assemblies to scan for a validator</param> public static void RegisterValidators(this Container container, params Assembly[] assemblies) { var autoWire = new ExpressionTypeFunqContainer(container); foreach (var assembly in assemblies) { foreach (var validator in assembly.GetTypes() .Where(t => t.IsOrHasGenericInterfaceTypeOf(typeof(IValidator <>)))) { RegisterValidator(autoWire, validator); } } }
public FunqControllerFactory(Container container) { this.funqBuilder = new ExpressionTypeFunqContainer(container) { Scope = ReuseScope.None //don't re-use instances }; // Also register all the controller types as transient var controllerTypes = from type in Assembly.GetExecutingAssembly().GetTypes() where typeof(IController).IsAssignableFrom(type) select type; funqBuilder.RegisterTypes(controllerTypes); }
private static void RegisterValidator(ExpressionTypeFunqContainer autoWire, Type validator) { var baseType = validator.BaseType; while (!baseType.IsGenericType) { baseType = baseType.BaseType; } var dtoType = baseType.GetGenericArguments()[0]; var validatorType = typeof(IValidator <>).MakeGenericType(dtoType); autoWire.RegisterType(validator, validatorType); }
public void Can_AutoWire_types_dynamically_with_expressions() { var serviceType = typeof(AutoWireService); var container = new Container(); container.Register<IFoo>(c => new Foo()); container.Register<IBar>(c => new Bar()); var typeContainer = new ExpressionTypeFunqContainer(container); typeContainer.RegisterTypes(serviceType); var service = container.Resolve<AutoWireService>(); Assert.That(service.Foo, Is.Not.Null); Assert.That(service.Bar, Is.Not.Null); }
public void Can_AutoWire_types_dynamically_with_expressions() { var serviceType = typeof(AutoWireService); var container = new Container(); container.Register <IFoo>(c => new Foo()); container.Register <IBar>(c => new Bar()); var typeContainer = new ExpressionTypeFunqContainer(container); typeContainer.RegisterTypes(serviceType); var service = container.Resolve <AutoWireService>(); Assert.That(service.Foo, Is.Not.Null); Assert.That(service.Bar, Is.Not.Null); }
public void Init() { var typeFactory = new ExpressionTypeFunqContainer(this.Container); this.ServiceController.Register(typeFactory); this.ServiceOperations = new ServiceOperations(this.ServiceController.OperationTypes); this.AllServiceOperations = new ServiceOperations(this.ServiceController.AllOperationTypes); typeFactory.RegisterTypes(this.ServiceController.ServiceTypes); }
/// <summary> /// Register an autowired dependency /// </summary> /// <typeparam name="T"></typeparam> public void RegisterAutoWired <T>() { var autoWired = new ExpressionTypeFunqContainer(this); autoWired.Register <T>(); }