예제 #1
0
 public override Variable CreateInlineVariable(ResolverVariables variables)
 {
     return(new Setter(ServiceType, inlineSetterName())
     {
         InitialValue = Service
     });
 }
예제 #2
0
        protected override Variable generateVariableForBuilding(ResolverVariables variables, BuildMode mode, bool isRoot)
        {
            // This is goofy, but if the current service is the top level root of the resolver
            // being created here, make the dependencies all be Dependency mode
            var dependencyMode = isRoot && mode == BuildMode.Build ? BuildMode.Dependency : mode;

            var elements = Elements.Select(x => variables.Resolve(x, dependencyMode)).ToArray();

            return(new ListAssignmentFrame <T>(this, elements).Variable);
        }
예제 #3
0
        public override Frame CreateBuildFrame()
        {
            var variables = new ResolverVariables();
            var elements  = _elements.Select(x => variables.Resolve(x, BuildMode.Dependency)).ToArray();

            return(new ArrayAssignmentFrame <T>(this, elements)
            {
                ReturnCreated = true
            });
        }
예제 #4
0
파일: CtorArg.cs 프로젝트: JasperFx/lamar
        public Variable Resolve(ResolverVariables variables, BuildMode mode)
        {
            var variable = variables.Resolve(Instance, mode);

            if (Parameter.Name.EqualsIgnoreCase(variable.Usage))
            {
                variable.OverrideName("inline_" + variable.Usage);
            }

            return(variable);
        }
예제 #5
0
        public Variable Resolve(ResolverVariables variables, BuildMode mode)
        {
            if (Instance.IsInlineDependency())
            {
                return(Instance.CreateInlineVariable(variables));
            }

            var inner = variables.Resolve(Instance, mode);

            return(Parameter.IsOptional
                ? new OptionalArgumentVariable(inner, Parameter)
                : inner);
        }
예제 #6
0
        private void useInlineConstruction()
        {
            var variables = new ResolverVariables(_fields);

            foreach (var standin in _standins)
            {
                var variable = variables.Resolve(standin.Instance, BuildMode.Inline);
                standin.UseInner(variable);
            }

            variables.OfType <InjectedServiceField>().Each(field =>
            {
                var family      = _services.FindAll(field.VariableType);
                field.IsOnlyOne = family.Length == 1;
            });
        }
예제 #7
0
        public sealed override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
        {
            if (Lifetime == ServiceLifetime.Singleton)
            {
                if (mode == BuildMode.Build)
                {
                    return(generateVariableForBuilding(variables, mode, isRoot));
                }

                return(new InjectedServiceField(this));
            }

            if (Lifetime == ServiceLifetime.Scoped && mode == BuildMode.Dependency)
            {
                return(new GetInstanceFrame(this).Variable);
            }

            return(generateVariableForBuilding(variables, mode, isRoot));
        }
예제 #8
0
        public SetterArg Resolve(ResolverVariables variables, BuildMode mode)
        {
            Variable variable;

            if (Instance.IsInlineDependency())
            {
                variable = Instance.CreateInlineVariable(variables);

                // HOKEY. Might need some smarter way of doing this. Helps to disambiguate
                // between ctor args of nested decorators
                if (!(variable is Setter))
                {
                    variable.OverrideName(variable.Usage + "_inline_" + ++variables.VariableSequence);
                }
            }
            else
            {
                variable = variables.Resolve(Instance, mode);
            }

            return(new SetterArg(Property, variable));
        }
예제 #9
0
        public Variable Resolve(ResolverVariables variables, BuildMode mode)
        {
            if (Instance.IsInlineDependency())
            {
                var variable = Instance.CreateInlineVariable(variables);


                // HOKEY. Might need some smarter way of doing this. Helps to disambiguate
                // between ctor args of nested decorators
                if (!(variable is Setter))
                {
                    variable.OverrideName(variable.Usage + "_inline_" + ++variables.VariableSequence);
                }


                return(variable);
            }

            var inner = variables.Resolve(Instance, mode);

            return(Parameter.IsOptional
                ? new OptionalArgumentVariable(inner, Parameter)
                : inner);
        }
예제 #10
0
 public abstract Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot);
예제 #11
0
        public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
        {
            var settings = variables.Resolve(_settings, mode);

            return(new SqlConnectionFrame(settings, this).Connection);
        }
예제 #12
0
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     throw new NotImplementedException();
 }
예제 #13
0
파일: NullInstance.cs 프로젝트: yuzd/lamar
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     return(new NullVariable(ServiceType));
 }
예제 #14
0
 public override Variable CreateInlineVariable(ResolverVariables variables)
 {
     return(_inner.CreateInlineVariable(variables));
 }
예제 #15
0
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     return(new GetInjectedServiceFrame(this).Variable);
 }
예제 #16
0
 protected abstract Variable generateVariableForBuilding(ResolverVariables variables, BuildMode mode, bool isRoot);
예제 #17
0
        public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
        {
            var root = variables.Resolve(_root, mode);

            return(new MessagingRootFrame(this, root).Service);
        }
예제 #18
0
 public virtual Variable CreateInlineVariable(ResolverVariables variables)
 {
     return(CreateVariable(BuildMode.Dependency, variables, false));
 }
예제 #19
0
 protected override Variable generateVariableForBuilding(ResolverVariables variables, BuildMode mode, bool isRoot)
 {
     throw new NotImplementedException();
 }
예제 #20
0
 public Variable Resolve(ResolverVariables variables, BuildMode mode)
 {
     return(variables.Resolve(Instance, mode));
 }
예제 #21
0
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     return(new CastScopeFrame(typeof(T)).Variable);
 }
예제 #22
0
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     return(new GetFuncFrame(this, typeof(T)).Variable);
 }
예제 #23
0
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     return(_inner.CreateVariable(mode, variables, isRoot));
 }
예제 #24
0
 public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
 {
     return(new InjectedServiceField(this));
 }
예제 #25
0
        public override Variable CreateVariable(BuildMode mode, ResolverVariables variables, bool isRoot)
        {
            var root = variables.Resolve(_rootInstance, mode);

            return(new NewContextFrame(this, root).Variable);
        }