ExampleMenu.Examples.Procedures.ProcManager.GenerateInputForProc C# (CSharp) Method

GenerateInputForProc() public method

public GenerateInputForProc ( string name ) : IEnumerable
name string
return IEnumerable
        public IEnumerable<string> GenerateInputForProc(string name)
        {
            if (name == null) {
                throw new ArgumentNullException ("procname");
            }

            Proc proc;
            if (!_Procs.TryGetValue (name, out proc)) {
                Console.WriteLine ("Unknown procedure: " + proc);
                yield break;
            }

            int i = 0;
            while (i < proc.Commands.Count) {
                var line = proc.Commands[i];
                yield return line;
                i++;

                if (_RequestReturn) {
                    _RequestReturn = false;
                    break;
                }
                if (_RequestJump != null) {
                    int to;
                    if (proc.JumpMarks.TryGetValue (_RequestJump, out to)) {
                        i = to;
                    }
                    else {
                        Console.WriteLine ("Could not find jump target \"" + _RequestJump + "\", aborting.");
                        yield break;
                    }
                    _RequestJump = null;
                }
            }
        }

Usage Example

Exemplo n.º 1
0
 public override void Execute(string arg)
 {
     CQ.AddInput(_Mgr.GenerateInputForProc(arg));
 }