public string Match(string inputtedText) { // checks for match and returns the matched variable string or "" if no variable string, no match returns null string cleanText = StringModifier.RemovePunctuationAndWhiteSpace(inputtedText); string[] sections = RuleString.Split(VariableSymbol); string[] cleanSections = sections.Select(s => StringModifier.RemovePunctuationAndWhiteSpace(s)).ToArray <string>(); if (cleanSections.Length == 1) { // no variable symbol, fixed rule if (cleanText.Equals(cleanSections[0])) { return(""); } } else { // variable section, data-driven rule if (cleanText.StartsWith(cleanSections[0]) && cleanText.EndsWith(cleanSections[1])) { return(cleanText.Substring(cleanSections[0].Length, cleanText.Length - cleanSections[0].Length - cleanSections[1].Length)); } } // no match return(null); }
public GenBaseRow(ModuleGenerator generator, //Ссылка на генератор GenTemplateTable table, //Описание полей таблицы-шаблона DaoRec rec) //Рекордсет таблицы шаблона генерации { Table = table; Keeper = new GenKeeper(generator); RuleString = rec.GetString(Table.RuleField); if (!RuleString.IsEmpty()) { var parse = Table.IsSub ? new SubRuleParsing(Keeper, Table.RuleField, RuleString) : new RuleParsing(Keeper, Table.RuleField, RuleString); Rule = parse.ResultTree; } foreach (Field field in rec.Recordset.Fields) { var name = field.Name; if (!Table.IsSpecial(name) && !rec.IsNull(name)) { var dataType = field.Type.ToDataType(); if (dataType != DataType.String) { Fields.Add(name, new GenConstNode(rec.GetMean(dataType, name))); } else { string s = rec.GetString(name); if (!s.Contains("[")) { Fields.Add(name, new GenConstNode(null, s)); } else { var fparse = new FieldsParsing(Keeper, name, rec.GetString(name)); var f = (IExprNode)fparse.ResultTree; if (f != null) { Fields.Add(name, f); } } } } } }
public static void LoadRules(List <RuleString> Rules, TextAsset content) { using (StringReader reader = new StringReader(content.text)) { //Debug.Log ("#Arquivo OK"); //Leitura--------------------------------------- string line; while ((line = reader.ReadLine()) != null) { string[] parts = line.Split('/'); if (parts[0] == "#RULE" || parts[0] == "#Rule" || parts[0] == "#R" || parts[0] == "#r") { RuleString aux_rule = new RuleString(); aux_rule.name = parts[1]; string[] parts2 = parts[2].Split('='); aux_rule.left = parts2[0]; aux_rule.right = parts2[1]; Rules.Add(aux_rule); } } } }