private MultiDictionary <string, IConceptParser> CreateGenericParsers() { var stopwatch = Stopwatch.StartNew(); var conceptMetadata = _conceptInfoPlugins .Select(conceptInfo => conceptInfo.GetType()) .Distinct() .Select(conceptInfoType => new { conceptType = conceptInfoType, conceptKeyword = ConceptInfoHelper.GetKeyword(conceptInfoType) }) .Where(cm => cm.conceptKeyword != null) .ToList(); _keywordsLogger.Trace(() => string.Join(" ", conceptMetadata.Select(cm => cm.conceptKeyword).OrderBy(keyword => keyword).Distinct())); var result = conceptMetadata.ToMultiDictionary(x => x.conceptKeyword, x => { var parser = new GenericParser(x.conceptType, x.conceptKeyword); parser.OnMemberRead += _onMemberRead; return((IConceptParser)parser); }, StringComparer.OrdinalIgnoreCase); _performanceLogger.Write(stopwatch, "CreateGenericParsers."); return(result); }
private static ConceptType CreateConceptTypePartial(Type conceptInfoType) { if (!typeof(IConceptInfo).IsAssignableFrom(conceptInfoType)) { throw new ArgumentException($"Type '{conceptInfoType}' is not an implementation of '{typeof(IConceptInfo)}'."); } if (typeof(IConceptInfo) == conceptInfoType) { throw new ArgumentException($"{nameof(ConceptType)} cannot be created from {nameof(IConceptInfo)} interface. An implementation class is required."); } return(new ConceptType { AssemblyQualifiedName = conceptInfoType.AssemblyQualifiedName, BaseTypes = null, // Will be set later, because it needs to reference other ConceptTypes, after all are created. TypeName = conceptInfoType.Name, Keyword = ConceptInfoHelper.GetKeyword(conceptInfoType), Members = null, // Will be set later, to avoid recursive dependencies when creating these objects. }); }
protected IEnumerable <IConceptParser> CreateGenericParsers() { var stopwatch = Stopwatch.StartNew(); var conceptMetadata = _conceptInfoPlugins .Select(conceptInfo => conceptInfo.GetType()) .Distinct() .Select(conceptInfoType => new { conceptType = conceptInfoType, conceptKeyword = ConceptInfoHelper.GetKeyword(conceptInfoType) }) .Where(cm => cm.conceptKeyword != null) .ToList(); _keywordsLogger.Trace(() => string.Join(" ", conceptMetadata.Select(cm => cm.conceptKeyword).OrderBy(keyword => keyword).Distinct())); var result = conceptMetadata.Select(cm => new GenericParser(cm.conceptType, cm.conceptKeyword)).ToList <IConceptParser>(); _performanceLogger.Write(stopwatch, "DslParser.CreateGenericParsers."); return(result); }