public Variable Create(Type type) { var instance = _services.FindDefault(type); if (instance.Lifetime == ServiceLifetime.Singleton) { var field = _fields.FirstOrDefault(x => x.Instance == instance); if (field == null) { field = new InjectedServiceField(instance); _fields.Add(field); } return(field); } var standin = new ServiceStandinVariable(instance); _standins.Add(standin); return(standin); }
public void finds_the_single_default() { theServices.AddTransient <IWidget, AWidget>(); var theGraph = new ServiceGraph(theServices, Scope.Empty()); theGraph.Initialize(); theGraph.FindDefault(typeof(IWidget)) .ShouldBeOfType <ConstructorInstance>() .ImplementationType.ShouldBe(typeof(AWidget)); }
public bool Matches(Type type) { if (type == typeof(IServiceScopeFactory)) { return(true); } var descriptor = _graph.FindDefault(type); return(descriptor?.Lifetime == ServiceLifetime.Singleton); }
public void finds_the_single_default() { theServices.AddTransient <IWidget, AWidget>(); theGraph.FindDefault(typeof(IWidget)) .ImplementationType.ShouldBe(typeof(AWidget)); }
public Variable Create(Type type) { var @default = _services.FindDefault(type); BuildStepPlanner planner = null; if (@default?.ImplementationType != null && @default.Lifetime != ServiceLifetime.Singleton) { planner = new BuildStepPlanner(type, @default.ImplementationType, _services, _method); } return(new ServiceCreationFrame(type, planner).Service); }
protected override IEnumerable <Instance> createPlan(ServiceGraph services) { _settings = services.FindDefault(typeof(SqlServerSettings)); yield return(_settings); }
protected override IEnumerable <Instance> createPlan(ServiceGraph services) { _store = services.FindDefault(typeof(IStore)); yield return(_store); }
protected override IEnumerable <Instance> createPlan(ServiceGraph services) { _rootInstance = services.FindDefault(typeof(IMessagingRoot)); yield return(_rootInstance); }