// Spludlow Software // Copyright © Samuel P. Ludlow 2020 All Rights Reserved // Distributed under the terms of the GNU General Public License version 3 // Distributed WITHOUT ANY WARRANTY; without implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE // https://www.spludlow.co.uk/LICENCE.TXT // The Spludlow logo is a registered trademark of Samuel P. Ludlow and may not be used without permission // v1.14 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; namespace Spludlow { [Serializable] public class CallSet { public CallMethod[] Calls; public int CallIndex; public int Hop; public string Trace; public string Schedule; public CallSet() { } public CallSet(Dictionary> arguments) { if (arguments.Keys.Count == 1 && arguments.ContainsKey("") == true) { List list = arguments[""]; if (list.Count == 1) { // load from file } else { if (list.Count < 3) throw new ApplicationException("Must at least supply A T M."); } } else { this.Construct(new CallMethod(arguments)); } } public CallSet(CallMethod call) { this.Construct(call); } public CallSet(CallMethod[] calls) { this.Construct(calls); } public void Construct(CallMethod call) { this.Construct(new CallMethod[] { call }); } public void Construct(CallMethod[] calls) { this.Calls = calls; this.CallIndex = 0; this.Hop = 0; if (calls.Length == 0) throw new ApplicationException("CallsInfo; No calls"); } public void Reset() { this.CallIndex = 0; this.Hop = 0; this.Trace = null; foreach (CallMethod method in this.Calls) { method.PickUpQueue = null; method.Result = null; } } public string Write2() { StringBuilder text = new StringBuilder(); text.AppendLine("#\tSpludlow CallSet Text"); text.AppendLine("#\tCallIndex\t" + this.CallIndex); text.AppendLine("#\tHop\t" + this.Hop); text.AppendLine("#\tCalls Length\t" + this.Calls.Length); for (int index = 0; index < this.Calls.Length; ++index) { Spludlow.CallMethod method = this.Calls[index]; text.AppendLine("#\tMethod:\t" + index); text.AppendLine(Spludlow.CallText.Write2(method, method.Parameters, method.ConstructorArguments)); } return text.ToString(); } public CallMethod CurrentMethod { get { return this.Calls[this.CallIndex]; } } public CallMethod LastMethod { get { return this.Calls[this.Calls.Length - 1]; } } } }