private void BuilderFileContentItem(textfilecontent_item item, FileContentItemSystemData itemSystemData, textfilecontent_item fileContentItem) { item.line = new EntityItemStringType() { Value = itemSystemData.Line.ToString(), datatype = Modulo.Collect.OVAL.Common.SimpleDatatypeEnumeration.@string, status = StatusEnumeration.exists }; List<EntityItemAnySimpleType> destSubs = new List<EntityItemAnySimpleType>(); item.filename = new EntityItemStringType() { Value = itemSystemData.FileName.ToString(), datatype = Modulo.Collect.OVAL.Common.SimpleDatatypeEnumeration.@string, status = StatusEnumeration.exists }; foreach (string thisSub in itemSystemData.SubExpressions) destSubs.Add(new EntityItemAnySimpleType() { Value = thisSub, datatype = Modulo.Collect.OVAL.Common.SimpleDatatypeEnumeration.@string, status = StatusEnumeration.exists }); item.subexpression = destSubs.ToArray(); item.filepath = fileContentItem.filepath; item.path = fileContentItem.path; item.pattern = fileContentItem.pattern; item.status = StatusEnumeration.exists; }
public static List<FileContentItemSystemData> parseMatches(string dir, string fname, string line, string pattern, ref int instance) { List<FileContentItemSystemData> retList = new List<FileContentItemSystemData>(); Regex myRegex = new Regex(pattern); MatchCollection myMatches = myRegex.Matches(line); foreach (Match myMatch in myMatches) { FileContentItemSystemData retItem = new FileContentItemSystemData(); retItem.SubExpressions = new List<string>(); retItem.Line = line; retItem.Pattern = pattern; retItem.Text = myMatch.ToString(); retItem.Path = dir; retItem.FileName = fname; for (int i = 1; i < myMatch.Groups.Count; i++) retItem.SubExpressions.Add(myMatch.Groups[i].ToString()); retList.Add(retItem); } return retList; }