public static LineParseType IdentifyLineType(string strLine) { LineParseType lptReturn = LineParseType.BlankLine; if (strLine.StartsWith("#@")) { if (strLine.StartsWith(Global.GroupHeader)) { lptReturn = LineParseType.GroupStartLine; } else if (strLine.StartsWith(Global.EndOfGroup)) { lptReturn = LineParseType.GroupEndLine; } else if (strLine.StartsWith(Global.RulesetNameHeader)) { lptReturn = LineParseType.RulesetNameLine; } else if (strLine.StartsWith(Global.VariableHeader)) { lptReturn = LineParseType.SetVariableLine; } else if (strLine.StartsWith(Global.EndOfRules)) { lptReturn = LineParseType.EndRulesLine; } else if (strLine.StartsWith(Global.NotesHeader)) { lptReturn = LineParseType.NotesStartLine; } else if (strLine.StartsWith(Global.EndOfNotes)) { lptReturn = LineParseType.NotesEndLine; } else if (strLine.StartsWith(Global.AuthorHeader)) { lptReturn = LineParseType.AuthorLine; } } else if (string.IsNullOrEmpty(strLine) || strLine == "#") { lptReturn = LineParseType.BlankLine; } else if (strLine.StartsWith("# -")) { lptReturn = LineParseType.DividerLine; } else if (strLine.StartsWith("<<")) { lptReturn = LineParseType.RulesetLine; } return(lptReturn); }
public int MergeRuleset(string[] strArray, int nLineStart, dmContainer dmcParent) { int nReturn = nLineStart; //parses until it reaches the end of the group and returns the line number after the end of the group dmRuleset newRS = new dmRuleset(this); string tmpString = strArray[nReturn]; LineParseType tmpLPT = IdentifyLineType(tmpString); if (tmpLPT == LineParseType.RulesetNameLine) { Dictionary <string, string> itemParameters = GetParameters(strArray[nReturn]); foreach (KeyValuePair <string, string> item in itemParameters) { switch (item.Key) { case "NAME": newRS.Name = item.Value; break; case "COMMENT": newRS.Comment = item.Value; break; } } nReturn++; } newRS.Parse(strArray[nReturn]); if (!dmcParent.Rulesets.Contains(newRS)) { dmcParent.AddRuleset(newRS); } nReturn++; return(nReturn); }