コード例 #1
0
 private LocalBuilder GenerateDirectly(GeneratingDesign design)
 {
     return(design.Designer
            .DeclareVariable(design.ObjectGraph.ReturnType)
            .AssignTo(v => GenerateDependencyProviding(design))
            .Variable);
 }
コード例 #2
0
 protected static IReadOnlyList <LocalBuilder> GenerateForSubGraphs(GeneratingDesign design)
 {
     return(design.ObjectGraph.Children.Select(objectGraph => objectGraph.GeneratingStrategy.Generate(new GeneratingDesign
     {
         Designer = design.Designer,
         ObjectGraph = objectGraph
     })).ToList());
 }
コード例 #3
0
        public void Generate(GeneratingDesign design)
        {
            var parameters  = GenerateForSubGraphs(design);
            var elementType = design.ObjectGraph.ImplementationType.GetElementType();

            design.Designer
            .CreateNewArray(elementType, parameters.Count)
            .FillArray(parameters);
        }
コード例 #4
0
        protected override void GenerateDependencyProviding(GeneratingDesign design)
        {
            var          scope = _scopeKeeper.PerRequestScope;
            LocalBuilder instanceVariable;

            if (!scope.AvailableInstancesVariables.TryGetValue(design.ObjectGraph.ImplementationType, out instanceVariable))
            {
                instanceVariable = design.Designer
                                   .DeclareVariable(design.ObjectGraph.ImplementationType)
                                   .AssignTo(v =>
                {
                    scope.Add(design.ObjectGraph.ImplementationType, v);
                    _objectInstantiatingGenerator.Generate(design);
                })
                                   .Variable;
            }
            design.Designer.PushToStack(instanceVariable);
        }
コード例 #5
0
        protected override void GenerateDependencyProviding(GeneratingDesign design)
        {
            lock (this)
            {
                var instanceIndex    = GetInstanceIndex(design.ObjectGraph.ImplementationType);
                var instanceVariable = design.Designer.DeclareVariable <object>().Variable;

                design.Designer
                .LoadArgumentToStack(0)
                .LoadArrayRefElementTo(instanceVariable, instanceIndex)
                .If().IsNull(instanceVariable)
                .BeginBranch()
                .Action(() => _objectInstantiatingGenerator.Generate(design))
                .PopFromStackTo(instanceVariable)
                .LoadArgumentToStack(0)
                .SetArrayRefElement(instanceIndex, instanceVariable)
                .EndBranch()
                .PushToStack(instanceVariable)
                .CastToClass(design.ObjectGraph.ImplementationType);
            }
        }
 protected override void GenerateDependencyProviding(GeneratingDesign design)
 {
     _arrayInstantiatingGenerator.Generate(design);
 }
        public void Generate(GeneratingDesign design)
        {
            var resultVariable = design.ObjectGraph.GeneratingStrategy.Generate(design);

            design.Designer.ReturnStatement(resultVariable);
        }
コード例 #8
0
        public void Generate(GeneratingDesign design)
        {
            var parameters = GenerateForSubGraphs(design);

            design.Designer.CreateNewObject(design.ObjectGraph.Constructor, parameters);
        }
コード例 #9
0
 protected abstract void GenerateDependencyProviding(GeneratingDesign design);
コード例 #10
0
 public LocalBuilder Generate(GeneratingDesign design)
 {
     //return _cache.GetOrAdd(design.ObjectGraph.ImplementationType, t => GenerateDirectly(design));
     return(GenerateDirectly(design));
 }