private void C_Def(LineReader reader, string args) { string[] parts = Chop(args); string key = parts[0]; if (key.Length < 1 || key[0] < 'A' || key[0] > 'Z') throw new ArgumentException("#def name must start with capital A..Z"); string text = ReadCData(reader, "#enddef"); string[] arr = new string[parts.Length - 1]; Array.Copy(parts, 1, arr, 0, parts.Length - 1); _CustomCommands[key] = new CustomCommand(key, text, arr); }
private string ExecuteCustomCommand(CustomCommand cc, string argLines) { string[] args = argLines.Split(new string[] { "\r\n" }, StringSplitOptions.None); int n = Math.Min(args.Length, cc.Args.Length); for (int i = 0; i < n; i++) { string key = cc.Args[i]; string val = args[i]; _Macros[key] = val; } for (int i = n; i < cc.Args.Length; i++) { _Macros.Remove(cc.Args[i]); } using (var sw = new LineReader(cc.Text, name: cc.Name)) { return Run(sw); } }