public static void loadPlugins(string PluginPath = "") { if (string.IsNullOrEmpty(PluginPath)) { PluginPath = AppDomain.CurrentDomain.BaseDirectory; } _CatalogPlugins.Clear(); _SoftwarePlugins.Clear(); _SWLookupPlugins.Clear(); _FeedbackPlugins.Clear(); if (Base._cache != null) { Base._cache.Dispose(); //Clear Cache... } Base._cache = new MemoryCache(new MemoryCacheOptions()); Dictionary <string, string> dSettings = new Dictionary <string, string>(); //Load config.json if (File.Exists(Path.Combine(PluginPath, "config.json"))) { JArray jConfig = JArray.Parse(File.ReadAllText(Path.Combine(PluginPath, "config.json"))); foreach (JObject jPermission in jConfig) { string sName = jPermission["Name"].Value <string>(); dSettings.Add(sName + "URL", jPermission["URL"].Value <string>()); dSettings.Add(sName + "SAS", jPermission["SAS"].Value <string>().TrimStart('?')); } } ICollection <ICatalog> CATplugins = GenericPluginLoader <ICatalog> .LoadPlugins(PluginPath, "RZ.Plugin.Catalog"); foreach (var item in CATplugins) { _CatalogPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <ISoftware> SWplugins = GenericPluginLoader <ISoftware> .LoadPlugins(PluginPath, "RZ.Plugin.Software"); foreach (var item in SWplugins) { _SoftwarePlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <ISWLookup> Lookupplugins = GenericPluginLoader <ISWLookup> .LoadPlugins(PluginPath, "RZ.Plugin.SWLookup"); foreach (var item in Lookupplugins) { _SWLookupPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <IFeedback> Feedbackplugins = GenericPluginLoader <IFeedback> .LoadPlugins(PluginPath, "RZ.Plugin.Feedback"); foreach (var item in Feedbackplugins) { _FeedbackPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } Console.WriteLine(""); }
public static void loadPlugins(string PluginPath = "") { if (string.IsNullOrEmpty(PluginPath)) { PluginPath = AppDomain.CurrentDomain.BaseDirectory; } _CatalogPlugins.Clear(); _SoftwarePlugins.Clear(); _SWLookupPlugins.Clear(); _FeedbackPlugins.Clear(); _LogPlugins.Clear(); _CustomerPlugins.Clear(); dSettings.Clear(); if (Base._cache != null) { Base._cache.Dispose(); //Clear Cache... } Base._cache = new MemoryCache(new MemoryCacheOptions()); //depreciated: load config.json if (File.Exists(Path.Combine(PluginPath, "config.json"))) { Console.WriteLine("Loading Settings from config.json..."); JArray jConfig = JArray.Parse(File.ReadAllText(Path.Combine(PluginPath, "config.json"))); foreach (JObject jPermission in jConfig) { string sName = jPermission["Name"].Value <string>(); dSettings.Add(sName + "URL", jPermission["URL"].Value <string>()); dSettings.Add(sName + "SAS", jPermission["SAS"].Value <string>().TrimStart('?')); } } else { //Load Settings from Environent/KeyVault Console.WriteLine("Loading Settings from Environmanet/KeyVault..."); foreach (System.Collections.DictionaryEntry eVar in Environment.GetEnvironmentVariables()) { string sKey = eVar.Key.ToString().ToLower(); if (sKey.StartsWith("sas:")) { Plugins.dSettings.Add(sKey.Split(':')[1] + "URL", eVar.Value.ToString().Split('?')[0]); Plugins.dSettings.Add(sKey.Split(':')[1] + "SAS", eVar.Value.ToString().Split('?')[1]); } } } ICollection <ICatalog> CATplugins = GenericPluginLoader <ICatalog> .LoadPlugins(PluginPath, "RZ.Plugin.Catalog"); foreach (var item in CATplugins) { _CatalogPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <ISoftware> SWplugins = GenericPluginLoader <ISoftware> .LoadPlugins(PluginPath, "RZ.Plugin.Software"); foreach (var item in SWplugins) { _SoftwarePlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <ISWLookup> Lookupplugins = GenericPluginLoader <ISWLookup> .LoadPlugins(PluginPath, "RZ.Plugin.SWLookup"); foreach (var item in Lookupplugins) { _SWLookupPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <IFeedback> Feedbackplugins = GenericPluginLoader <IFeedback> .LoadPlugins(PluginPath, "RZ.Plugin.Feedback"); foreach (var item in Feedbackplugins) { _FeedbackPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <ILog> Logplugins = GenericPluginLoader <ILog> .LoadPlugins(PluginPath, "RZ.Plugin.Log"); foreach (var item in Logplugins) { _LogPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } ICollection <ICustomer> Customerplugins = GenericPluginLoader <ICustomer> .LoadPlugins(PluginPath, "RZ.Plugin.Customer"); foreach (var item in Customerplugins) { _CustomerPlugins.Add(item.Name, item); Console.WriteLine(item.Name); item.Settings = new Dictionary <string, string>(); item.Settings.Add("wwwPath", Directory.GetParent(PluginPath).FullName); item.Init(PluginPath); dSettings.ToList().ForEach(x => item.Settings.Add(x.Key, x.Value)); } }