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

            design.Designer
            .CreateNewArray(elementType, parameters.Count)
            .FillArray(parameters);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
        public void Generate(GeneratingDesign design)
        {
            var parameters = GenerateForSubGraphs(design);

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