public static bool AddTemplate(this CommandsTemplates commandsTemplates, string commandName, string templateDescription, string commandLine, bool overwrite) { Dictionary <string, string> templates; if (commandsTemplates.Templates.TryGetValue(commandName, out templates))//command templates exists { if (templates.ContainsKey(templateDescription)) { if (overwrite) { templates[templateDescription] = commandLine; } else { return(false); } } else { templates[templateDescription] = commandLine; } } else { templates = new Dictionary <string, string>(); commandsTemplates.Templates[commandName] = templates; templates[templateDescription] = commandLine; } commandsTemplates.MarkDirty(); return(true); }
public static void DeleteTemplate(this CommandsTemplates commandsTemplates, string commandName, string templateDescription) { Dictionary <string, string> commandDic; if (commandsTemplates.Templates.TryGetValue(commandName, out commandDic)) { if (commandDic.Remove(templateDescription)) { commandsTemplates.MarkDirty(); } } }