public static Decision GetUkPartDecision(Dictionary <int, IDecision> branches = null) { // default param branches = branches ?? new Dictionary <int, IDecision> { }; // Code // question and decision Action <IDecision, IDecision> question = (d, a) => { var decision = d as UkPartDecision; var answer = a as UkPartDecision; if (decision != null) { ///////////////// var branchChoice = 0; if (answer != null) { // automapper decision.UkPartEnum = answer.UkPartEnum; decision.Result = answer.Result; } else { // ask question Console.WriteLine("{0}", decision.Question); var ans = Console.ReadLine() ?? string.Empty; //var branchChoice = Convert.ToInt32(ans); //var branchChoice = (int)1; // assign/calculate properties of the decision decision.UkPartEnum = (UkPartEnum)Convert.ToInt32(ans); //decision.Amount = 7.4f; // assign branch choice given users answers decision.Result = branchChoice; } /// ////////////// } }; var retd = new UkPartDecision { Question = string.Format("[/1] {0} ?", Enum <UkPartEnum> .EnumsStringSummary()), Mutator = question, Branches = branches }; // Return return(retd); }
public static Decision GetUkPartDecision(Dictionary<int, IDecision> branches = null) { // default param branches = branches ?? new Dictionary<int, IDecision> { }; // Code // question and decision Action<IDecision, IDecision> question = (d, a) => { var decision = d as UkPartDecision; var answer = a as UkPartDecision; if (decision != null) { ///////////////// var branchChoice = 0; if (answer != null) { // automapper decision.UkPartEnum = answer.UkPartEnum; decision.Result = answer.Result; } else { // ask question Console.WriteLine("{0}", decision.Question); var ans = Console.ReadLine() ?? string.Empty; //var branchChoice = Convert.ToInt32(ans); //var branchChoice = (int)1; // assign/calculate properties of the decision decision.UkPartEnum = (UkPartEnum)Convert.ToInt32(ans); //decision.Amount = 7.4f; // assign branch choice given users answers decision.Result = branchChoice; } /// ////////////// } }; var retd = new UkPartDecision { Question = string.Format("[/1] {0} ?", Enum<UkPartEnum>.EnumsStringSummary()), Mutator = question, Branches = branches }; // Return return retd; }