예제 #1
0
        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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        public bool Matches(Type type)
        {
            if (type == typeof(IServiceScopeFactory))
            {
                return(true);
            }

            var descriptor = _graph.FindDefault(type);

            return(descriptor?.Lifetime == ServiceLifetime.Singleton);
        }
예제 #4
0
        public void finds_the_single_default()
        {
            theServices.AddTransient <IWidget, AWidget>();

            theGraph.FindDefault(typeof(IWidget))
            .ImplementationType.ShouldBe(typeof(AWidget));
        }
예제 #5
0
        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);
 }
예제 #7
0
 protected override IEnumerable <Instance> createPlan(ServiceGraph services)
 {
     _store = services.FindDefault(typeof(IStore));
     yield return(_store);
 }
예제 #8
0
 protected override IEnumerable <Instance> createPlan(ServiceGraph services)
 {
     _rootInstance = services.FindDefault(typeof(IMessagingRoot));
     yield return(_rootInstance);
 }