Пример #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
        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
 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);
        }