public ServiceController(ServiceStackHost appHost, Assembly[] assembliesWithServices, Func <IEnumerable <Type> > resolveServicesFn) { AppHost = appHost; appHost.Container.DefaultOwner = Owner.External; typeFactory = new ContainerResolveCache(); this.RequestTypeFactoryMap = new Dictionary <Type, Func <IRequest, object> >(); this.ResolveServicesFn = resolveServicesFn ?? (() => Service.GetServiceTypes(assembliesWithServices ?? appHost.ServiceAssemblies)); }
public ServiceController Init() { typeFactory = new ContainerResolveCache(appHost.Container); this.Register(typeFactory); appHost.Container.RegisterAutoWiredTypes(appHost.Metadata.ServiceTypes); return(this); }
public ServiceController Init() { typeFactory = new ContainerResolveCache(appHost.Container); this.Register(typeFactory); appHost.Container.RegisterAutoWiredTypes(appHost.Metadata.ServiceTypes); return this; }
/// <summary> /// Initializes a new instance of the <see cref="FunqControllerFactory" /> class. /// </summary> /// <param name="container">The container.</param> /// <param name="assemblies">The assemblies to reflect for IController discovery.</param> public FunqControllerFactory(Container container, params Assembly[] assemblies) { this.funqBuilder = new ContainerResolveCache(container); // aggregate the local and external assemblies for processing (unless ignored) IEnumerable<Assembly> targetAssemblies = assemblies.Concat(new[] { Assembly.GetCallingAssembly() }); foreach (var assembly in targetAssemblies) { // Also register all the controller types as transient var controllerTypes = (from type in assembly.GetTypes() where typeof(IController).IsAssignableFrom(type) select type).ToList(); container.RegisterAutoWiredTypes(controllerTypes); } }
public void CreateInstance_throws_on_missing_dependency() { using (var appHost = new BasicAppHost().Init()) { var services = appHost.Container; services.AddTransient<IFoo, Foo>(); var typeFactory = new ContainerResolveCache(appHost.Container); var foo = typeFactory.CreateInstance(services, typeof(IFoo), tryResolve: true); Assert.That(foo, Is.Not.Null); var bar = typeFactory.CreateInstance(services, typeof(IBar), tryResolve: true); Assert.That(bar, Is.Null); Assert.Throws<ResolutionException>(() => typeFactory.CreateInstance(services, typeof(IBar), tryResolve: false)); } }
public FunqValidatorFactory(Container container=null) { this.funqBuilder = new ContainerResolveCache(container ?? HostContext.Container); }
public FunqValidatorFactory(Container container=null) { this.funqBuilder = new ContainerResolveCache(container ?? AppHostBase.Instance.Container); }