/// <summary> /// Populates the cache. /// </summary> /// <param name="cache">Cache.</param> private void PopulateCache(ZptDocumentProviderCache cache) { if(cache == null) { throw new ArgumentNullException(nameof(cache)); } var allProviders = (from assembly in GetAllPluginAssemblies() from type in base.GetConcreteTypes<IZptDocumentProvider>(assembly) select new { Type = type, Provider = (IZptDocumentProvider) Activator.CreateInstance(type) }) .ToArray(); foreach(var kvp in allProviders) { cache.Add(kvp.Type, kvp.Provider); } var defaultHtml = allProviders .SingleOrDefault(x => x.Type.FullName == PluginConfig.GetDefaultHtmlDocumentProviderTypeName()); if(defaultHtml != null) { cache.DefaultHtmlProvider = defaultHtml.Provider; } var defaultXml = allProviders .SingleOrDefault(x => x.Type.FullName == PluginConfig.GetDefaultXmlDocumentProviderTypeName()); if(defaultXml != null) { cache.DefaultXmlProvider = defaultXml.Provider; } }
/// <summary> /// Initializes the <see cref="CSF.Zpt.ZptDocumentProviderService"/> class. /// </summary> static ZptDocumentProviderService() { _cache = new ZptDocumentProviderCache(); }