public ILogSource CreateParser(IServiceContainer services, ILogSource source) { var format = source.GetProperty(Properties.Format); var logSourceParserPlugins = _pluginLoader?.LoadAllOfTypeWithDescription <ILogSourceParserPlugin>() ?? Enumerable.Empty <IPluginWithDescription <ILogSourceParserPlugin> >(); foreach (var plugin in logSourceParserPlugins) { var parser = TryCreateParser(plugin, source); if (parser != null) { return(parser); } } var logEntryParserPlugins = _pluginLoader?.LoadAllOfTypeWithDescription <ILogEntryParserPlugin>() ?? Enumerable.Empty <IPluginWithDescription <ILogEntryParserPlugin> >(); foreach (var plugin in logEntryParserPlugins) { var parser = TryCreateParser(plugin, format); if (parser != null) { return(new GenericTextLogSource(source, parser)); } } return(new GenericTextLogSource(source, new GenericTextLogEntryParser())); }
private IReadOnlyList <IPluginWithDescription <IPlugin> > GetOrLoad <T>() where T : class, IPlugin { if (!_loadedPlugins.TryGetValue(typeof(T), out var plugins)) { var tmp = _pluginLoader.LoadAllOfTypeWithDescription <T>(); if (tmp != null) { plugins = new List <IPluginWithDescription <IPlugin> >(tmp); } else { plugins = new List <IPluginWithDescription <IPlugin> >(); } _loadedPlugins.Add(typeof(T), plugins); } return(plugins); }
public LogFileFormatRegistry(IPluginLoader pluginLoader, ICustomFormatsSettings customFormats) { var creators = pluginLoader.LoadAllOfTypeWithDescription <ICustomLogFileFormatCreatorPlugin>(); var creatorsById = new Dictionary <PluginId, ICustomLogFileFormatCreatorPlugin>(creators.Count); foreach (var description in creators) { if (description.Plugin != null) { creatorsById.Add(description.Description.Id, description.Plugin); } } _creatorsById = creatorsById; _formatsByCustomFormat = new Dictionary <CustomLogFileFormat, ILogFileFormat>(); _syncRoot = new object(); _formats = new List <ILogFileFormat>(); foreach (var customFormat in customFormats) { TryAdd(customFormat); } }