public override CmdResult ExecuteRequest(CmdRequest args) { string filename; if (args.TryGetValue("save", out filename)) { FileStream w = null; try { w = File.OpenWrite(filename); StreamWriter sw = new StreamWriter(w); SysVarHtml((s, args0) => { try { sw.WriteLine(DLRConsole.SafeFormat(s, args0)); } catch (Exception) { return; } }, true); } finally { if (w != null) { w.Close(); } ; } return(Success("Wrote " + filename)); } if (args.TryGetValue("load", out filename)) { LoadSysVarHtml(File.OpenRead(filename)); return(Success("Loaded " + filename)); } if (args.ContainsFlag("htmldoc")) { StringBuilder sw = new StringBuilder(1024 * 900); SysVarHtml((s, ags) => sw.AppendFormat(s, ags), false); return(Success(sw.ToString())); } bool exactMatch = args.ContainsFlag("--exact"); bool caseSensitive = args.ContainsFlag("--case"); int used = 0; var sysvars = GetSysVars(); string find; if (!args.TryGetValueOr("key", 0, out find)) { // display all foreach (var sv in sysvars) { var svv = sv; WriteLine(string.Format("{0}={1} //{2}", (svv.Key), svv.Value, svv.Comments)); } return(Success("count=" + sysvars.Count)); } if (!caseSensitive) { find = find.ToLower(); } var setThese = ScriptManager.FindMatchingSysvars(sysvars, find, exactMatch, caseSensitive); int found = 0; foreach (var svv in setThese) { { found++; WriteLine(svv.DebugInfo); } } string value; if (!args.TryGetValueOr("value", 1, out value)) { return(Success("Found sysvars: " + found)); } int changed = 0; foreach (var one in setThese) { try { one.Value = value; AddSuccess("Set sysvar: " + one.Key + " to " + one.Value); changed++; } catch (Exception e) { } } return(Success("set vars = " + changed)); }
public override CmdResult ExecuteRequest(CmdRequest args) { string filename; if (args.TryGetValue("save", out filename)) { FileStream w = null; try { w = File.OpenWrite(filename); StreamWriter sw = new StreamWriter(w); SysVarHtml((s, args0) => { try { sw.WriteLine(DLRConsole.SafeFormat(s, args0)); } catch (Exception) { return; } }, true); } finally { if (w != null) w.Close(); ; } return Success("Wrote " + filename); } if (args.TryGetValue("load", out filename)) { LoadSysVarHtml(File.OpenRead(filename)); return Success("Loaded " + filename); } if (args.ContainsFlag("htmldoc")) { StringBuilder sw = new StringBuilder(1024*900); SysVarHtml((s, ags) => sw.AppendFormat(s, ags), false); return Success(sw.ToString()); } bool exactMatch = args.ContainsFlag("--exact"); bool caseSensitive = args.ContainsFlag("--case"); int used = 0; var sysvars = GetSysVars(); string find; if (!args.TryGetValueOr("key", 0, out find)) { // display all foreach (var sv in sysvars) { var svv = sv; WriteLine(string.Format("{0}={1} //{2}", (svv.Key), svv.Value, svv.Comments)); } return Success("count=" + sysvars.Count); } if (!caseSensitive) find = find.ToLower(); var setThese = ScriptManager.FindMatchingSysvars(sysvars, find, exactMatch, caseSensitive); int found = 0; foreach (var svv in setThese) { { found++; WriteLine(svv.DebugInfo); } } string value; if (!args.TryGetValueOr("value", 1, out value)) { return Success("Found sysvars: " + found); } int changed = 0; foreach (var one in setThese) { try { one.Value = value; AddSuccess("Set sysvar: " + one.Key + " to " + one.Value); changed++; } catch (Exception e) { } } return Success("set vars = " + changed); }