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); }
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); }
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); }
protected abstract void GenerateDependencyProviding(GeneratingDesign design);
public LocalBuilder Generate(GeneratingDesign design) { //return _cache.GetOrAdd(design.ObjectGraph.ImplementationType, t => GenerateDirectly(design)); return(GenerateDirectly(design)); }