/// <summary> /// A EventPattern can be tag with a FileType. Using such a EventPattern the system will determine the type of file. /// </summary> private static BuildSourceTypeDetail BuildSourceType(FileData file) { var result = new BuildSourceTypeDetail(); lock (file) { var start = DateTime.Now; if (file.IsCached_SourceType) { result.SourceTypeDuration = DateTime.Now - start; return(result); } // Default to Unknown file.SourceType = Keywords.SOURCE_TYPE_UNKNOWN; var stopWatch = new Stopwatch(MethodBase.GetCurrentMethod().Name, false); var count = 0; try { var test = XmlDal.DataModel.EventsModel.Events.Where(n => n.SourceType != null).ToList(); result.SourceTypeEventCount = test.Count(); foreach (var e in test) { count++; var firstMatch = RegularExpression.GetFirstMatch(file.RawTextStringFirstLines, e.RegularExpression); if (firstMatch.Captures.Count == 0) { continue; } var startGetLine = DateTime.Now; file.SourceTypeiLine = RegularExpression.GetLine(file.RawTextStringFirstLines, firstMatch); result.GetLineDuration = DateTime.Now - startGetLine; file.SourceType = e.SourceType; break; } XmlDal.CacheModel.Options.UpdateCachedSourceType(file.SourceType, file.Path); } finally { file.IsCached_SourceType = true; stopWatch.Stop(); } result.SourceTypeEventScans = count; result.SourceTypeDuration = DateTime.Now - start; return(result); } }
public BuildDetail() { RangeDetail = new BuildRangeDetail(); NonLazyValuesDetail = new BuildNonLazyValuesDetail(); SourceTypeDetail = new BuildSourceTypeDetail(); }