public ClassTemplateImpl(IGenerateSerie gen, IUseMethod pMethod) : base(gen) { Method = pMethod; Level = (uint)pMethod.Level; pMethod.Implementation = (IGetBase)this; idSerie = Method.IdMethod; }
public void Print(IUseMethod Method) { HelperUI.ModifyMethod(tree, () => { PrintMethods printer = new PrintMethods(tree); printer.Print(Method); tree.ExpandAll(); ShowDialog(); }); }
private static IGetString GetInstanceNoAsync(IUseMethod method, IGenerateSerie reporter, IGetBase lastClass) { if (method == null) { return(null); } var processing = StrategyTodoFactory.GetInstance(method.TypeDoIndependentWork, reporter, method.NumSteps); IStrategyTodo todo = StrategyTodoFactory.GetInstance(method.TypeDoIndependentWork, reporter, method.NumSteps); MyWorkSync myW = new MyWorkSync(todo, reporter); if (method.Next == null) { return(new MethodSyncFinal(myW, reporter, processing, method)); } else { IGetString result = null; if (lastClass is IGetString) { result = new CallNextSyncIfNextMethodIsSync(myW, (IGetString)lastClass, reporter, method); } else if (lastClass is IGetStringAsync) { switch (method.CallNext) { case ECallNext.WAIT_FIRST: result = new CallNextSyncWaitFirstIfNextMethodIsAsync(myW, (IGetStringAsync)lastClass, reporter, method); break; case ECallNext.WAIT_AFTER: case ECallNext.AWAITER_AFTER: case ECallNext.NOT_WAIT: result = new CallNextSyncWaitAfterIfNextMethodIsAsync(myW, (IGetStringAsync)lastClass, reporter, method); break; } } return(result); } }
public static IGetBase GetInstance(IUseMethod method, IGenerateSerie reporter) { if (method == null) { return(null); } IGetBase result = null; var lastClass = GetInstance(method.Next, reporter); if (method.TypeImpl == ETypeImpl.ASYNC) { result = GetInstanceAsync(method, reporter, lastClass); } else if (method.TypeImpl == ETypeImpl.SYNC) { result = GetInstanceNoAsync(method, reporter, lastClass); } return(result); }
public MethodSync(IMyWorkSync pMyWork, IGenerateSerie gen, IUseMethod pMethod) : base(gen, pMethod) { DoIndependetWork = pMyWork; }
public MethodSyncWithNext(IMyWorkSync pMyWork, IGetBase pNext, IGenerateSerie gen, IUseMethod pMethod) : base(pMyWork, gen, pMethod) { Next = pNext; }
public MethodSyncFinal(IMyWorkSync pMyWork, IGenerateSerie gen, IStrategyTodo pProcesamiento, IUseMethod pMethod) : base(pMyWork, gen, pMethod) { }
public CallNextSyncWaitAfterIfNextMethodIsAsync(IMyWorkSync pMyWork, IGetStringAsync pNext, IGenerateSerie gen, IUseMethod pMethod) : base(pMyWork, pNext, gen, pMethod) { }
public CallNextSyncIfNextMethodIsSync(IMyWorkSync pMyWork, IGetString pNext, IGenerateSerie gen, IUseMethod pMethod) : base(pMyWork, pNext, gen, pMethod) { }
public CallNextAsyncWaitFirst(IMyWorkASync pMyWork, IGetStringAsync pNext, IGenerateSerie gen, IUseMethod pMethod) : base(pMyWork, pNext, gen, pMethod) { }
public void Print(IUseMethod parameter) { if (parameter == null || parameter.Implementation == null) { return; } string literal = parameter.IdMethod; var color = colors[parameter.Level % colors.Length]; if (parameter.Level == 0) { colorNext = color; } TreeNode parent = current ?? tree.Nodes[tree.Nodes.Count - 1]; if (string.IsNullOrWhiteSpace(callNext)) { current = Write(parent, literal + " " + (parameter.Implementation is IGetString ? " Main()" : "MainAsync()"), colorNext); } else { current = Write(parent, callNext, colorNext); var colorHeader = colors[parameter.Level % colors.Length]; current = Write(current, literal + " " + (parameter.Implementation is IGetString ? " Main()" : "MainAsync()"), colorHeader); } colorNext = color; var current2 = current; string nextImp, getNextSting, todo; nextImp = getNextSting = ""; if (parameter.Implementation is ICallNextDescription) { nextImp = ((ICallNextDescription)parameter.Implementation).PreDescription(); getNextSting = ((ICallNextDescription)parameter.Implementation).PostDescription(); } todo = parameter.Implementation.DoIndependetWork.Description(); var todoStrategy = parameter.Implementation.DoIndependetWork.StrategyTodo?.Description(); if (parameter.Next != null) { nextImp = nextImp.Replace("Next", parameter.Next.IdMethod); callNext = @"VAR X" + parameter.Level + " = " + nextImp; Print(parameter.Next); var indpenWork = Write(current2, @"VAR Y" + parameter.Level + " = " + todo, color); indpenWork = Write(indpenWork, "DoIndependentWork()", color); Write(indpenWork, todoStrategy, color); getNextSting = getNextSting.Replace("Next", "X" + parameter.Level); Write(current2, @"Return" + " Y" + parameter.Level + " + " + getNextSting, color); } else { var indpenWork = Write(current2, @"Return " + todo, color); indpenWork = Write(indpenWork, "DoIndependentWork()", color); Write(indpenWork, todoStrategy, color); } }
private void bttCreateMethods_Click(object sender, EventArgs e) { this.Enabled = false; var selected = (int)cmbLevels.SelectedItem; panelMethodsFlow.Controls.Clear(); int topLocation = 0; List <IUseMethod> methods = new List <IUseMethod>(); int height = 0; int width = 0; for (int i = 1; i <= selected; i++) { UseMethod Met = new UseMethod(); if (i == 1) { height = Met.Height + 15; width = Met.Width + 20; Method = Met; } //Met.EventChange = null; Met.Level = i; Met.Name = "useMethod" + i; Met.Next = null; Met.NumSteps = DefaulttrackMethod; Met.Size = new System.Drawing.Size(446, 89); Met.TabIndex = 30; Met.TypeDoIndependentWork = DefaultETypeWork; Met.TypeImpl = DefaultETypeImplementation; Met.CallNext = DefaultECallNext; Met.StrategyDoIndependentWork = DefaultDoIndependentWork; topLocation = i * (Met.Height + 1); // Met.Location = new System.Drawing.Point(0, topLocation); panelMethodsFlow.Controls.Add(Met); methods.Add(Met); } panelMethodsFlow.Width = width; panelMethodsFlow.Height = (methods.Count * height); PLeftMain.MaximumSize = new System.Drawing.Size() { Width = width + 20 }; PLeftMain.Width = width + 15; methods.Reverse(); IUseMethod current = null; foreach (var auxMet in methods) { auxMet.Next = current; current = auxMet; } this.Enabled = true; }
private static IGetStringAsync GetInstanceAsync(IUseMethod method, IGenerateSerie reporter, IGetBase lastClass) { if (method == null) { return(null); } var processing = StrategyTodoFactory.GetInstance(method.TypeDoIndependentWork, reporter, method.NumSteps); IStrategyTodo todo = StrategyTodoFactory.GetInstance(method.TypeDoIndependentWork, reporter, method.NumSteps); MyWorkAsync myW = null; switch (method.StrategyDoIndependentWork) { case EStrategyDoIndependentWork.WRAPPER_ASYNC: myW = new MyWorkAsyncWait(todo, reporter); break; case EStrategyDoIndependentWork.WRAPPER_ASYNC_AWAITER: myW = new MyWorkAsyncAwaiter(todo, reporter); break; case EStrategyDoIndependentWork.NORMAL: myW = new MyWorkAsyncNotWait(todo, reporter); break; } if (method.Next == null) { return(new MainAsyncFinal(myW, reporter, processing, method)); } else { IGetStringAsync result = null; if (lastClass is IGetStringAsync) { switch (method.CallNext) { case ECallNext.WAIT_FIRST: result = new CallNextAsyncWaitFirst(myW, (IGetStringAsync)lastClass, reporter, method); break; case ECallNext.WAIT_AFTER: result = new CallNextAsyncWaitAfter(myW, (IGetStringAsync)lastClass, reporter, method); break; case ECallNext.AWAITER_AFTER: result = new CallNextAsyncAwaiter(myW, (IGetStringAsync)lastClass, reporter, method); break; case ECallNext.NOT_WAIT: result = new CallNextAsyncNotWait(myW, (IGetStringAsync)lastClass, reporter, method); break; } } else { result = new CallNextAsyncToSync(myW, (IGetString)lastClass, reporter, method); } return(result); } }