private void ParseSection() { try { // Match sections using regex MatchCollection matches = Regex.Matches(rawData, @"^\[(.+)\]\r?$", RegexOptions.Compiled | RegexOptions.Multiline); // Make instances of sections for (int i = 0; i < matches.Count; i++) { int secDataOffset = 0; int secDataLen = 0; secDataOffset = matches[i].Index + matches[i].Length + 1; if (i + 1 < matches.Count) { secDataLen = matches[i + 1].Index - secDataOffset; } else { secDataLen = rawData.Length - secDataOffset; } string secName = matches[i].Value.Substring(1, matches[i].Length - 3); string[] secLines = rawData.Substring(secDataOffset, secDataLen).Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); sections[secName] = new PluginSection(secName, secLines); } } catch (Exception e) { Console.WriteLine(string.Concat(e.GetType(), ": ", Helper.RemoveLastNewLine(e.Message))); } }
/// <summary> /// Run an plugin /// </summary> public void RunPlugin() { LoadDefaultPluginVariables(); PluginSection section = plugins[curPluginIdx].Sections["Process"]; nextCommand = new CommandAddress(section, 0, section.SecLines.Length); RunCommands(); return; }
public CommandAddress(PluginSection section, int line, int secLength) { this.section = section; this.line = line; this.secLength = secLength; }
/// <summary> /// Add local variables /// </summary> /// <param name="section"></param> public void GlobalAddVariables(PluginSection section) { StringDictionary dict = Helper.ParseVarStyle(section.SecLines); InternalAddDictionary(globalVars, dict); }