From 5fd4f341531d6d17b9dcfe8aa9d16c5453654e6b Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Tue, 12 Feb 2013 17:24:47 +1100 Subject: [PATCH] Remove obsolete plugin references --- .../CertificateProviderLog.cs | 304 ------------------ .../CertificateProviderPlugin.cs | 23 -- .../InteroperabilityProviderPlugin.cs | 17 - .../WarrantyProviderPlugin.cs | 52 --- .../WarrantyProviderSubmitJobException.cs | 12 - .../_Plugins/IPluginConfiguration.cs | 16 - .../_Plugins/IPluginWebController.cs | 13 - .../_Plugins/InvalidCategoryTypeException.cs | 50 --- Disco.Services/_Plugins/Plugin.cs | 28 -- .../_Plugins/PluginCategoryAttribute.cs | 13 - Disco.Services/_Plugins/PluginDefinition.cs | 86 ----- Disco.Services/_Plugins/PluginExtensions.cs | 75 ----- .../_Plugins/PluginWebControllerException.cs | 15 - .../_Plugins/PluginWebControllerExtensions.cs | 210 ------------ Disco.Services/_Plugins/Plugins.cs | 290 ----------------- Disco.Services/_Plugins/PluginsLog.cs | 259 --------------- .../_Plugins/UnknownPluginException.cs | 37 --- 17 files changed, 1500 deletions(-) delete mode 100644 Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderLog.cs delete mode 100644 Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderPlugin.cs delete mode 100644 Disco.Services/_Plugins/Categories/InteroperabilityProvider/InteroperabilityProviderPlugin.cs delete mode 100644 Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderPlugin.cs delete mode 100644 Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderSubmitJobException.cs delete mode 100644 Disco.Services/_Plugins/IPluginConfiguration.cs delete mode 100644 Disco.Services/_Plugins/IPluginWebController.cs delete mode 100644 Disco.Services/_Plugins/InvalidCategoryTypeException.cs delete mode 100644 Disco.Services/_Plugins/Plugin.cs delete mode 100644 Disco.Services/_Plugins/PluginCategoryAttribute.cs delete mode 100644 Disco.Services/_Plugins/PluginDefinition.cs delete mode 100644 Disco.Services/_Plugins/PluginExtensions.cs delete mode 100644 Disco.Services/_Plugins/PluginWebControllerException.cs delete mode 100644 Disco.Services/_Plugins/PluginWebControllerExtensions.cs delete mode 100644 Disco.Services/_Plugins/Plugins.cs delete mode 100644 Disco.Services/_Plugins/PluginsLog.cs delete mode 100644 Disco.Services/_Plugins/UnknownPluginException.cs diff --git a/Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderLog.cs b/Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderLog.cs deleted file mode 100644 index 36c2dbc1..00000000 --- a/Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderLog.cs +++ /dev/null @@ -1,304 +0,0 @@ -using Disco.Services.Logging; -using Disco.Services.Logging.Models; -using System; -using System.Collections.Generic; -using System.Diagnostics; -namespace Disco.Services.Plugins.Categories.CertificateProvider -{ - public class CertificateProvidersLog : LogBase - { - public enum EventTypeIds - { - RetrievalStarting = 10, - RetrievalProgress, - RetrievalFinished, - RetrievalWarning = 15, - RetrievalError, - RetrievalCertificateStarting = 20, - RetrievalCertificateFinished = 22, - RetrievalCertificateWarning = 25, - RetrievalCertificateError, - Allocated = 40, - AllocationFailed = 50 - } - private const int _ModuleId = 60; - private static bool _IsCertificateRetrievalProcessing; - private static string _CertificateRetrievalStatus; - private static int _CertificateRetrievalProgress; - public static CertificateProvidersLog Current - { - get - { - return (CertificateProvidersLog)LogContext.LogModules[60]; - } - } - public static bool IsCertificateRetrievalProcessing - { - get - { - return CertificateProvidersLog._IsCertificateRetrievalProcessing; - } - } - public override string ModuleDescription - { - get - { - return "Certificate Providers"; - } - } - public override int ModuleId - { - get - { - return 60; - } - } - public override string ModuleName - { - get - { - return "CertificateProviders"; - } - } - [System.Diagnostics.DebuggerNonUserCode] - public CertificateProvidersLog() - { - } - private static void Log(CertificateProvidersLog.EventTypeIds EventTypeId, params object[] Args) - { - CertificateProvidersLog.Current.Log((int)EventTypeId, Args); - } - public static void LogRetrievalStarting(int CertificateCount, int CertificateIdFrom, int CertificateIdTo) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalStarting, new object[] - { - CertificateCount, - CertificateIdFrom, - CertificateIdTo - }); - } - public static void LogRetrievalFinished() - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalFinished, new object[0]); - } - public static void LogRetrievalWarning(string Message) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalWarning, new object[] - { - Message - }); - } - public static void LogRetrievalError(string Message) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalError, new object[] - { - Message - }); - } - public static void LogRetrievalCertificateStarting(string CertificateId) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateStarting, new object[] - { - CertificateId - }); - } - public static void LogRetrievalCertificateFinished(string CertificateId) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateFinished, new object[] - { - CertificateId - }); - } - public static void LogRetrievalCertificateWarning(string CertificateId, string Message) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateWarning, new object[] - { - CertificateId, - Message - }); - } - public static void LogRetrievalCertificateError(string CertificateId, string Message) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateError, new object[] - { - CertificateId, - Message - }); - } - public static void LogAllocated(string CertificateId, string DeviceSerialNumber) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.Allocated, new object[] - { - CertificateId, - DeviceSerialNumber - }); - } - public static void LogAllocationFailed(string DeviceSerialNumber) - { - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.AllocationFailed, new object[] - { - DeviceSerialNumber - }); - } - public static void LogCertificateRetrievalProgress(bool? IsProcessing, int? Progress, string Status) - { - bool flag = IsProcessing.HasValue; - if (flag) - { - CertificateProvidersLog._IsCertificateRetrievalProcessing = IsProcessing.Value; - } - flag = CertificateProvidersLog._IsCertificateRetrievalProcessing; - if (flag) - { - bool flag2 = Status != null; - if (flag2) - { - CertificateProvidersLog._CertificateRetrievalStatus = Status; - } - flag2 = Progress.HasValue; - if (flag2) - { - CertificateProvidersLog._CertificateRetrievalProgress = Progress.Value; - } - } - else - { - CertificateProvidersLog._CertificateRetrievalStatus = null; - CertificateProvidersLog._CertificateRetrievalProgress = 0; - } - CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalProgress, new object[] - { - CertificateProvidersLog._IsCertificateRetrievalProcessing, - CertificateProvidersLog._CertificateRetrievalProgress, - CertificateProvidersLog._CertificateRetrievalStatus - }); - } - protected override System.Collections.Generic.List LoadEventTypes() - { - return new System.Collections.Generic.List - { - new LogEventType - { - Id = 10, - ModuleId = 60, - Name = "Retrieval Starting", - Format = "Starting retrieval of {0} certificate/s ({1} to {2})", - Severity = 0, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 11, - ModuleId = 60, - Name = "Retrieval Progress", - Format = "Processing: {0}; {1}% Complete; Status: {2}", - Severity = 0, - UseLive = true, - UsePersist = false, - UseDisplay = false - }, - new LogEventType - { - Id = 12, - ModuleId = 60, - Name = "Retrieval Finished", - Format = "Retrieval of Certificates Complete", - Severity = 0, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 15, - ModuleId = 60, - Name = "Retrieval Warning", - Format = "Retrieval Warning: {0}", - Severity = 1, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 16, - ModuleId = 60, - Name = "Retrieval Error", - Format = "Retrieval Error: {0}", - Severity = 2, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 20, - ModuleId = 60, - Name = "Retrieval Certificate Starting", - Format = "Retrieving Certificate: {0}", - Severity = 0, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 22, - ModuleId = 60, - Name = "Retrieval Certificate Finished", - Format = "Certificate Retrieved: {0}", - Severity = 0, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 25, - ModuleId = 60, - Name = "Retrieval Certificate Warning", - Format = "{0} Certificate Warning: {1}", - Severity = 1, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 26, - ModuleId = 60, - Name = "Retrieval Certificate Error", - Format = "{0} Certificate Error: {1}", - Severity = 2, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 40, - ModuleId = 60, - Name = "Allocated", - Format = "Certificate {0} allocated to {1}", - Severity = 0, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = 50, - ModuleId = 60, - Name = "Allocation Failed", - Format = "No certificates available for Device: {0}", - Severity = 2, - UseLive = true, - UsePersist = true, - UseDisplay = true - } - }; - } - } -} diff --git a/Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderPlugin.cs b/Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderPlugin.cs deleted file mode 100644 index c1cf4153..00000000 --- a/Disco.Services/_Plugins/Categories/CertificateProvider/CertificateProviderPlugin.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; -using Disco.Models.Repository; - -namespace Disco.Services.Plugins.Categories.CertificateProvider -{ - [PluginCategory(DisplayName = "Certificate Providers")] - public abstract class CertificateProviderPlugin : Plugin - { - public override sealed Type PluginCategoryType - { - get { return typeof(CertificateProviderPlugin); } - } - - // Certificate Plugin Requirements - public abstract string CertificateProviderId { get; } - public abstract Tuple> AllocateCertificate(DiscoDataContext dbContext, Device Device); - - } -} diff --git a/Disco.Services/_Plugins/Categories/InteroperabilityProvider/InteroperabilityProviderPlugin.cs b/Disco.Services/_Plugins/Categories/InteroperabilityProvider/InteroperabilityProviderPlugin.cs deleted file mode 100644 index 66be1088..00000000 --- a/Disco.Services/_Plugins/Categories/InteroperabilityProvider/InteroperabilityProviderPlugin.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Disco.Services.Plugins.Categories.InteroperabilityProvider -{ - [PluginCategory(DisplayName = "Interoperability Providers")] - public abstract class InteroperabilityProviderPlugin : Plugin - { - public override sealed Type PluginCategoryType - { - get { return typeof(InteroperabilityProviderPlugin); } - } - } -} diff --git a/Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderPlugin.cs b/Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderPlugin.cs deleted file mode 100644 index 05439ef9..00000000 --- a/Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderPlugin.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web.Mvc; -using Disco.Data.Repository; -using Disco.Models.BI.Config; -using Disco.Models.Repository; - -namespace Disco.Services.Plugins.Categories.WarrantyProvider -{ - [PluginCategory(DisplayName = "Warranty Providers")] - public abstract class WarrantyProviderPlugin : Plugin - { - public override sealed Type PluginCategoryType - { - get { return typeof(WarrantyProviderPlugin); } - } - - // Warranty Plugin Requirements - public abstract string WarrantyProviderId { get; } - public abstract Type SubmitJobViewType { get; } - public abstract dynamic SubmitJobViewModel(DiscoDataContext dbContext, Controller controller, Job Job, OrganisationAddress Address, User TechUser); - public abstract Dictionary SubmitJobParseProperties(DiscoDataContext dbContext, FormCollection form, Controller controller, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription); - public abstract Dictionary SubmitJobDiscloseInfo(DiscoDataContext dbContext, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary WarrantyProviderProperties); - public abstract string SubmitJob(DiscoDataContext dbContext, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary WarrantyProviderProperties); - - public abstract Type JobDetailsViewType { get; } - public bool JobDetailsSupported { get { return this.JobDetailsViewType != null; } } - public abstract dynamic JobDetailsViewModel(DiscoDataContext dbContext, Controller controller, Job Job); - - public static PluginDefinition FindPlugin(string PlugIdOrWarrantyProviderId) - { - var defs = Plugins.GetPlugins(typeof(WarrantyProviderPlugin)); - var def = defs.FirstOrDefault(d => d.Id.Equals(PlugIdOrWarrantyProviderId, StringComparison.InvariantCultureIgnoreCase)); - if (def != null) - return def; - else - foreach (var d in defs) - { - using (var providerInstance = d.CreateInstance()) - { - if (providerInstance.WarrantyProviderId != null && providerInstance.WarrantyProviderId.Equals(PlugIdOrWarrantyProviderId, StringComparison.InvariantCultureIgnoreCase)) - { - return d; - } - } - } - - return null; - } - } -} diff --git a/Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderSubmitJobException.cs b/Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderSubmitJobException.cs deleted file mode 100644 index c582d74b..00000000 --- a/Disco.Services/_Plugins/Categories/WarrantyProvider/WarrantyProviderSubmitJobException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace Disco.Services.Plugins.Categories.WarrantyProvider -{ - public class WarrantyProviderSubmitJobException : Exception - { - public WarrantyProviderSubmitJobException(string Message) - : base(Message) - { - } - } -} diff --git a/Disco.Services/_Plugins/IPluginConfiguration.cs b/Disco.Services/_Plugins/IPluginConfiguration.cs deleted file mode 100644 index 83c5c678..00000000 --- a/Disco.Services/_Plugins/IPluginConfiguration.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; -using System.Web.Mvc; - -namespace Disco.Services.Plugins -{ - public interface IPluginConfiguration - { - Type ConfigurationViewType { get; } - dynamic ConfigurationViewModel(DiscoDataContext dbContext, Controller controller); - bool ConfigurationSave(DiscoDataContext dbContext, FormCollection form, Controller controller); - } -} diff --git a/Disco.Services/_Plugins/IPluginWebController.cs b/Disco.Services/_Plugins/IPluginWebController.cs deleted file mode 100644 index 8256c569..00000000 --- a/Disco.Services/_Plugins/IPluginWebController.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web.Mvc; - -namespace Disco.Services.Plugins -{ - public interface IPluginWebController - { - ActionResult ExecuteAction(string ActionName, Controller HostController); - } -} diff --git a/Disco.Services/_Plugins/InvalidCategoryTypeException.cs b/Disco.Services/_Plugins/InvalidCategoryTypeException.cs deleted file mode 100644 index 66990a78..00000000 --- a/Disco.Services/_Plugins/InvalidCategoryTypeException.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Disco.Services.Plugins -{ - public class InvalidCategoryTypeException : Exception - { - private string _pluginRequested; - private Type _categoryType; - - public string PluginRequested - { - get - { - return _pluginRequested; - } - } - public Type CategoryType - { - get - { - return _categoryType; - } - } - - public InvalidCategoryTypeException(Type CategoryType) - : this(CategoryType, null) - { - } - public InvalidCategoryTypeException(Type CategoryType, string PluginRequested) - { - this._categoryType = CategoryType; - this._pluginRequested = PluginRequested; - } - - public override string Message - { - get - { - if (string.IsNullOrEmpty(_pluginRequested)) - return string.Format("Invalid Category Type [{0}]", _categoryType.Name); - else - return string.Format("Plugin [{1}] is not of the correct Category Type [{0}]", _categoryType.Name, _pluginRequested); - } - } - - } -} diff --git a/Disco.Services/_Plugins/Plugin.cs b/Disco.Services/_Plugins/Plugin.cs deleted file mode 100644 index 6079ce52..00000000 --- a/Disco.Services/_Plugins/Plugin.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; -using System.Web.Mvc; - -namespace Disco.Services.Plugins -{ - public abstract class Plugin : IDisposable - { - public string Id { get { return this.GetType().Name; } } - public abstract string Name { get; } - public abstract string Author { get; } - public abstract Version Version { get; } - - public abstract Type PluginCategoryType { get; } - - public abstract bool Initalize(DiscoDataContext dbContext); - - public abstract void Dispose(); - - public override sealed string ToString() - { - return string.Format("{0} ({1}) - v{2}", this.Name, this.Id, this.Version.ToString(3)); - } - } -} diff --git a/Disco.Services/_Plugins/PluginCategoryAttribute.cs b/Disco.Services/_Plugins/PluginCategoryAttribute.cs deleted file mode 100644 index d2ec3d4e..00000000 --- a/Disco.Services/_Plugins/PluginCategoryAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Disco.Services.Plugins -{ - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] - public class PluginCategoryAttribute : Attribute - { - public string DisplayName { get; set; } - } -} diff --git a/Disco.Services/_Plugins/PluginDefinition.cs b/Disco.Services/_Plugins/PluginDefinition.cs deleted file mode 100644 index 1393e4fa..00000000 --- a/Disco.Services/_Plugins/PluginDefinition.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Reflection; -using System.Web.Mvc; - -namespace Disco.Services.Plugins -{ - public class PluginDefinition - { - public string Id { get; private set; } - public string Name { get; private set; } - public string Author { get; private set; } - public Version Version { get; private set; } - - public Type PluginType { get; private set; } - public Type PluginCategoryType { get; private set; } - - public Dictionary PluginReferenceAssemblies { get; private set; } - public string PluginHostDirectory { get; private set; } - - public bool HasConfiguration { get; private set; } - public bool HasWebController { get; private set; } - - public PluginDefinition(Plugin PluginInstance, string HostDirectory, Dictionary ReferencedAssemblies = null) - { - Type pluginType = PluginInstance.GetType(); - - if (string.IsNullOrWhiteSpace(PluginInstance.Id)) - throw new ArgumentNullException("PluginInstance.Id"); - if (string.IsNullOrWhiteSpace(PluginInstance.Name)) - throw new ArgumentNullException("PluginInstance.Name"); - if (string.IsNullOrWhiteSpace(PluginInstance.Author)) - throw new ArgumentNullException("PluginInstance.Author"); - if (string.IsNullOrWhiteSpace(HostDirectory)) - throw new ArgumentNullException("HostDirectory"); - if (PluginInstance.Version == null) - throw new ArgumentNullException("PluginInstance.Version"); - if (PluginInstance.PluginCategoryType == null) - throw new ArgumentNullException("PluginInstance.PluginCategoryType"); - if (!PluginInstance.PluginCategoryType.IsAssignableFrom(pluginType)) - throw new ArgumentException(string.Format("The plugin [{0}] does not inherit the Category [{1}]", pluginType.Name, PluginInstance.PluginCategoryType.Name), "PluginInstance.PluginCategoryType"); - - this.Id = PluginInstance.Id; - this.Name = PluginInstance.Name; - this.Author = PluginInstance.Author; - this.Version = PluginInstance.Version; - this.PluginType = pluginType; - this.PluginCategoryType = PluginInstance.PluginCategoryType; - - this.PluginHostDirectory = HostDirectory; - - if (ReferencedAssemblies != null && ReferencedAssemblies.Count > 0) - this.PluginReferenceAssemblies = ReferencedAssemblies; - - // Determine (and Validate) if has Configuration - IPluginConfiguration pluginConfiguration = PluginInstance as IPluginConfiguration; - if (pluginConfiguration != null) - { - if (pluginConfiguration.ConfigurationViewType == null) - throw new ArgumentNullException("PluginInstance.ConfigurationViewType"); - if (!typeof(WebViewPage).IsAssignableFrom(pluginConfiguration.ConfigurationViewType)) - throw new ArgumentException(string.Format("The plugin [{0}] ConfigurationViewType must inherit System.Web.Mvc.WebViewPage", pluginType.Name), "PluginInstance.ConfigurationViewType"); - - this.HasConfiguration = true; - } - - // Determine if has Web Controller - IPluginWebController pluginWebController = PluginInstance as IPluginWebController; - this.HasWebController = (pluginWebController != null); - } - - public Plugin CreateInstance() - { - return (Plugin)Activator.CreateInstance(PluginType); - } - public PluginType CreateInstance() - { - if (typeof(PluginType).IsAssignableFrom(this.PluginType)) - return (PluginType)Activator.CreateInstance(this.PluginType); - else - throw new InvalidOperationException(string.Format("The plugin [{0}] cannot be cast into type [{1}]", this.PluginType.Name, typeof(PluginType).Name)); - } - } -} diff --git a/Disco.Services/_Plugins/PluginExtensions.cs b/Disco.Services/_Plugins/PluginExtensions.cs deleted file mode 100644 index 1bab88b3..00000000 --- a/Disco.Services/_Plugins/PluginExtensions.cs +++ /dev/null @@ -1,75 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Data.Repository; -using System.IO; -using System.Web.Mvc; -using System.Web.Routing; -using System.Web; - -namespace Disco.Services.Plugins -{ - public static class PluginExtensions - { - public static string PluginStorage(this Plugin plugin, DiscoDataContext dbContext) - { - string pluginStorageLocationRoot = dbContext.DiscoConfiguration.PluginStorageLocation; - - string storageLocation = Path.Combine(pluginStorageLocationRoot, plugin.Id); - - if (!Directory.Exists(storageLocation)) - Directory.CreateDirectory(storageLocation); - - return storageLocation; - } - - public static string PluginCategoryDisplayName(this Plugin plugin) - { - if (plugin == null) - throw new ArgumentNullException("plugin"); - - return Plugins.CategoryDisplayNames[plugin.PluginCategoryType]; - } - - #region Model Binding from Controller - public static bool TryUpdateModel(this Controller controller, TModel model) where TModel : class - { - return controller.TryUpdateModel(model, null, controller.ValueProvider); - } - public static bool TryUpdateModel(this Controller controller, TModel model, IValueProvider valueProvider) where TModel : class - { - return controller.TryUpdateModel(model, null, valueProvider); - } - public static bool TryUpdateModel(this Controller controller, TModel model, string prefix) where TModel : class - { - return controller.TryUpdateModel(model, prefix, controller.ValueProvider); - } - public static bool TryUpdateModel(this Controller controller, TModel model, string prefix, IValueProvider valueProvider) where TModel : class - { - if (model == null) - throw new ArgumentNullException("model"); - if (valueProvider == null) - throw new ArgumentNullException("valueProvider"); - - Predicate predicate = propertyName => true; - IModelBinder binder = ModelBinders.Binders.GetBinder(typeof(TModel)); - - ModelBindingContext context2 = new ModelBindingContext - { - ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, typeof(TModel)), - ModelName = prefix, - ModelState = controller.ModelState, - PropertyFilter = predicate, - ValueProvider = valueProvider - }; - - ModelBindingContext bindingContext = context2; - - binder.BindModel(controller.ControllerContext, bindingContext); - - return controller.ModelState.IsValid; - } - #endregion - } -} diff --git a/Disco.Services/_Plugins/PluginWebControllerException.cs b/Disco.Services/_Plugins/PluginWebControllerException.cs deleted file mode 100644 index 74dc16e2..00000000 --- a/Disco.Services/_Plugins/PluginWebControllerException.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Disco.Services.Plugins -{ - public class PluginWebControllerException : Exception - { - public PluginWebControllerException(string PluginId, string PluginAction, Exception InnerException) - : base(string.Format("An error occurred executing the Disco Plugin [{0}] Web Controller Action: [{0}]", PluginId, PluginAction), InnerException) - { - } - } -} diff --git a/Disco.Services/_Plugins/PluginWebControllerExtensions.cs b/Disco.Services/_Plugins/PluginWebControllerExtensions.cs deleted file mode 100644 index 52c86c07..00000000 --- a/Disco.Services/_Plugins/PluginWebControllerExtensions.cs +++ /dev/null @@ -1,210 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web.Routing; -using System.Web.Mvc; -using RazorGenerator.Mvc; -using System.IO; - -namespace Disco.Services.Plugins -{ - public static class PluginWebControllerExtensions - { - #region Virtual Directories - public static string WebControllerRootUrl(this IPluginWebController plugin, RequestContext requestContext) - { - var tempPath = plugin.WebControllerActionUrl(requestContext, "_"); - return tempPath.Substring(0, tempPath.LastIndexOf(@"/") + 1); - } - public static string WebControllerActionUrl(this IPluginWebController plugin, RequestContext requestContext, string PluginAction) - { - //return string.Format("~/Config/Plugins/{0}/{1}", HttpUtility.UrlEncode(((IDiscoPlugin)plugin).Id), HttpUtility.UrlEncode(PluginAction)); - var routeValues = new RouteValueDictionary(new { PluginId = ((Plugin)plugin).Id, PluginAction = PluginAction }); - return UrlHelper.GenerateUrl("Config_Plugins_PluginWebControllerActions", "PluginAction", "Plugins", routeValues, RouteTable.Routes, requestContext, true); - } - #endregion - - #region Action Results - - #region Compiled View - private static string[] _viewFileNames = new string[] { "cshtml" }; - public static ActionResult CompiledView(this Controller HostController, Type CompiledViewType, object Model, bool UseDiscoLayout) - { - string layoutPath = UseDiscoLayout ? "~/Views/Shared/_Layout.cshtml" : null; - - IView v = new PrecompiledMvcView(HostController.Request.Path, layoutPath, CompiledViewType, false, _viewFileNames); - - if (Model != null) - HostController.ViewData.Model = Model; - - return new ViewResult { View = v, ViewData = HostController.ViewData, TempData = HostController.TempData }; - } - public static ActionResult CompiledView(this Controller HostController, Type CompiledViewType, bool UseDiscoLayout) - { - return HostController.CompiledView(CompiledViewType, null, UseDiscoLayout); - } - public static ActionResult CompiledView(this Controller HostController, Type CompiledViewType, object Model) - { - return HostController.CompiledView(CompiledViewType, Model, true); - } - public static ActionResult CompiledView(this Controller HostController, Type CompiledViewType) - { - return HostController.CompiledView(CompiledViewType, false, true); - } - public static ActionResult CompiledPartialView(this Controller HostController, Type PartialCompiledViewType, object Model) - { - IView v = new PrecompiledMvcView(HostController.Request.Path, PartialCompiledViewType, false, _viewFileNames); - - if (Model != null) - HostController.ViewData.Model = Model; - - return new PartialViewResult { View = v, ViewData = HostController.ViewData, TempData = HostController.TempData }; - } - public static ActionResult CompiledPartialView(this Controller HostController, Type PartialCompiledViewType) - { - return HostController.CompiledView(PartialCompiledViewType, null); - } - #endregion - - #region Content - public static ActionResult Content(this Controller HostController, string content, string contentType, Encoding contentEncoding) - { - return new ContentResult { Content = content, ContentType = contentType, ContentEncoding = contentEncoding }; - } - public static ActionResult Content(this Controller HostController, string content, string contentType) - { - return HostController.Content(content, null, null); - } - public static ActionResult Content(this Controller HostController, string content) - { - return HostController.Content(content, null); - } - #endregion - - #region Json - public static ActionResult Json(this Controller HostController, object data, JsonRequestBehavior behavior) - { - return new JsonResult { Data = data, ContentType = null, ContentEncoding = null, JsonRequestBehavior = behavior }; - } - #endregion - - #region File - public static ActionResult File(this Controller HostController, Stream fileStream, string contentType) - { - return HostController.File(fileStream, contentType, null); - } - public static ActionResult File(this Controller HostController, Stream fileStream, string contentType, string fileDownloadName) - { - return new FileStreamResult(fileStream, contentType) { FileDownloadName = fileDownloadName }; - } - public static ActionResult File(this Controller HostController, byte[] fileContents, string contentType) - { - return HostController.File(fileContents, contentType, null); - } - public static ActionResult File(this Controller HostController, byte[] fileContents, string contentType, string fileDownloadName) - { - return new FileContentResult(fileContents, contentType) { FileDownloadName = fileDownloadName }; - } - #endregion - - #region HttpNotFound - public static ActionResult HttpNotFound(this Controller HostController, string statusDescription) - { - return new HttpNotFoundResult(statusDescription); - } - public static ActionResult HttpNotFound(this Controller HostController) - { - return HostController.HttpNotFound(null); - } - #endregion - - #region Redirect - public static ActionResult RedirectToScheduledTaskStatus(this Controller HostController, string SessionId) - { - if (string.IsNullOrEmpty(SessionId)) - throw new ArgumentNullException(SessionId); - - return HostController.RedirectToAction("TaskStatus", "Logging", "Config", new { id = SessionId }); - } - public static ActionResult Redirect(this Controller HostController, string url) - { - if (string.IsNullOrEmpty(url)) - throw new ArgumentNullException("url"); - - return new RedirectResult(url); - } - public static ActionResult RedirectPermanent(this Controller HostController, string url) - { - if (string.IsNullOrEmpty(url)) - throw new ArgumentNullException("url"); - - return new RedirectResult(url, true); - } - public static ActionResult RedirectToAction(this Controller HostController, IPluginWebController Plugin, string PluginAction) - { - if (string.IsNullOrEmpty(PluginAction)) - throw new ArgumentNullException("PluginAction"); - - string pluginActionUrl = Plugin.WebControllerActionUrl(HostController.Request.RequestContext, PluginAction); - return new RedirectResult(pluginActionUrl, false); - } - public static ActionResult RedirectToRoute(this Controller HostController, string routeName, object routeValues) - { - RouteValueDictionary routeValueDictionary; - if (routeValues != null) - routeValueDictionary = new RouteValueDictionary(routeValues); - else - routeValueDictionary = new RouteValueDictionary(); - - return new RedirectToRouteResult(routeName, routeValueDictionary); - } - public static ActionResult RedirectToRoute(this Controller HostController, string routeName) - { - return HostController.RedirectToRoute(routeName, null); - } - public static ActionResult RedirectToAction(this Controller HostController, string actionName, string controllerName, string areaName, object routeValues) - { - RouteValueDictionary routeValueDictionary; - if (routeValues != null) - routeValueDictionary = new RouteValueDictionary(routeValues); - else - routeValueDictionary = new RouteValueDictionary(); - - routeValueDictionary["action"] = actionName; - routeValueDictionary["controller"] = controllerName; - if (areaName != null) - routeValueDictionary["area"] = areaName; - - return new RedirectToRouteResult(routeValueDictionary); - } - public static ActionResult RedirectToAction(this Controller HostController, string actionName, string controllerName, string areaName) - { - return HostController.RedirectToAction(actionName, controllerName, areaName, null); - } - public static ActionResult RedirectToAction(this Controller HostController, string actionName, string controllerName, object routeValues) - { - return HostController.RedirectToAction(actionName, controllerName, null, routeValues); - } - public static ActionResult RedirectToAction(this Controller HostController, string actionName, string controllerName) - { - return HostController.RedirectToAction(actionName, controllerName, null, null); - } - public static ActionResult RedirectToDiscoJob(this Controller HostController, int jobId) - { - return HostController.RedirectToAction("Show", "Job", null, new { id = jobId.ToString() }); - } - public static ActionResult RedirectToDiscoDevice(this Controller HostController, string DeviceSerialNumber) - { - return HostController.RedirectToAction("Show", "Device", null, new { id = DeviceSerialNumber }); - } - public static ActionResult RedirectToDiscoUser(this Controller HostController, string UserId) - { - return HostController.RedirectToAction("Show", "User", null, new { id = UserId }); - } - #endregion - - #endregion - - } -} diff --git a/Disco.Services/_Plugins/Plugins.cs b/Disco.Services/_Plugins/Plugins.cs deleted file mode 100644 index a1fc58ae..00000000 --- a/Disco.Services/_Plugins/Plugins.cs +++ /dev/null @@ -1,290 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Reflection; -using Disco.Data.Repository; -using System.IO; -using System.ComponentModel.DataAnnotations; -using System.Web; -using System.Web.Mvc; -using RazorGenerator.Mvc; -using System.Web.WebPages; - -namespace Disco.Services.Plugins -{ - public static class Plugins - { - private static Dictionary _LoadedPlugins; - internal static Dictionary CategoryDisplayNames; - - private static object _PluginLock = new object(); - - public static string PluginPath { get; private set; } - - public static PluginDefinition GetPlugin(string PluginId, Type CategoryType = null) - { - if (_LoadedPlugins == null) - throw new InvalidOperationException("Plugins have not been initialized"); - - PluginDefinition def; - if (_LoadedPlugins.TryGetValue(PluginId, out def)) - { - if (CategoryType == null) - return def; - else - { - if (CategoryType.IsAssignableFrom(def.PluginCategoryType)) - return def; - else - throw new InvalidCategoryTypeException(CategoryType, PluginId); - } - } - else - { - throw new UnknownPluginException(PluginId); - } - } - public static List GetPlugins(Type CategoryType) - { - if (_LoadedPlugins == null) - throw new InvalidOperationException("Plugins have not been initialized"); - - return _LoadedPlugins.Values.Where(p => p.PluginCategoryType.IsAssignableFrom(CategoryType)).OrderBy(p => p.Name).ToList(); - } - public static List GetPlugins() - { - if (_LoadedPlugins == null) - throw new InvalidOperationException("Plugins have not been initialized"); - - return _LoadedPlugins.Values.ToList(); - } - - public static string PluginCategoryDisplayName(Type CategoryType) - { - if (CategoryType == null) - throw new ArgumentNullException("CategoryType"); - - string displayName; - if (CategoryDisplayNames.TryGetValue(CategoryType, out displayName)) - return displayName; - else - throw new InvalidOperationException(string.Format("Unknown Plugin Category Type: [{0}]", CategoryType.Name)); - } - - #region Initalizing - - public static void InitalizePlugins(DiscoDataContext dbContext) - { - if (_LoadedPlugins == null) - { - lock (_PluginLock) - { - if (_LoadedPlugins == null) - { - Dictionary loadedPlugins = new Dictionary(); - - PluginPath = dbContext.DiscoConfiguration.PluginsLocation; - - AppDomain appDomain = AppDomain.CurrentDomain; - - // Subscribe to Assembly Resolving - appDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; - - // Load Internal (Default?) Plugins - IEnumerable discoAssemblies = (from a in appDomain.GetAssemblies() - where !a.GlobalAssemblyCache && !a.IsDynamic && - a.FullName.StartsWith("Disco.", StringComparison.InvariantCultureIgnoreCase) - select a); - foreach (var discoAssembly in discoAssemblies) - { - List assemblyPluginDefinitions = InitializePluginAssembly(dbContext, discoAssembly, false); - foreach (PluginDefinition definition in assemblyPluginDefinitions) - loadedPlugins[definition.Id] = definition; - } - - // Load External (DataStore) Plugins - DirectoryInfo pluginDirectoryRoot = new DirectoryInfo(PluginPath); - if (pluginDirectoryRoot.Exists) - { - foreach (DirectoryInfo pluginDirectory in pluginDirectoryRoot.EnumerateDirectories()) - { - string pluginAssemblyFilename = Path.Combine(pluginDirectory.FullName, string.Format("{0}.dll", pluginDirectory.Name)); - if (File.Exists(pluginAssemblyFilename)) - { - Assembly pluginAssembly = null; - try - { - pluginAssembly = Assembly.LoadFile(pluginAssemblyFilename); - - if (pluginAssembly != null) - { - PluginsLog.LogInitializingPluginAssembly(pluginAssembly); - List assemblyPluginDefinitions = InitializePluginAssembly(dbContext, pluginAssembly, true); - foreach (PluginDefinition definition in assemblyPluginDefinitions) - loadedPlugins[definition.Id] = definition; - } - } - catch (Exception ex) { PluginsLog.LogInitializeException(pluginAssemblyFilename, ex); } - } - } - } - - // Determine Category Information - CategoryDisplayNames = InitializeCategoryDetails(loadedPlugins.Values); - - - _LoadedPlugins = loadedPlugins; - } - } - } - } - - private static Dictionary InitializeCategoryDetails(IEnumerable plugins) - { - Dictionary categoryDisplayNames = new Dictionary(); - foreach (var pluginDefinition in plugins) - { - if (!categoryDisplayNames.ContainsKey(pluginDefinition.PluginCategoryType)) - { - string displayName = null; - - var displayAttributes = pluginDefinition.PluginCategoryType.GetCustomAttributes(typeof(PluginCategoryAttribute), true); - if (displayAttributes != null && displayAttributes.Length > 0) - displayName = ((PluginCategoryAttribute)(displayAttributes[0])).DisplayName; - - if (string.IsNullOrWhiteSpace(displayName)) - displayName = pluginDefinition.PluginCategoryType.Name; - - categoryDisplayNames[pluginDefinition.PluginCategoryType] = displayName; - } - } - return categoryDisplayNames; - } - - private static List InitializePluginAssembly(DiscoDataContext dbContext, Assembly PluginAssembly, bool ResolveReferences) - { - List pluginDefinitions = new List(); - - var pluginTypes = (from type in PluginAssembly.GetTypes() - where typeof(Plugin).IsAssignableFrom(type) && !type.IsAbstract - select type).ToList(); - - if (pluginTypes.Count > 0) - { - Dictionary referencedAssemblies = null; - - string hostDirectory = Path.GetDirectoryName(PluginAssembly.Location); - - if (ResolveReferences) - referencedAssemblies = ImportReferencedAssemblies(PluginAssembly, hostDirectory); - - foreach (Type t in pluginTypes) - { - var p = InitializePlugin(dbContext, t, hostDirectory, referencedAssemblies); - if (p != null) - pluginDefinitions.Add(p); - } - - } - - return pluginDefinitions; - } - - private static Dictionary ImportReferencedAssemblies(Assembly PluginAssembly, string HostDirectory) - { - Dictionary referencedAssemblies = new Dictionary(); - foreach (string referenceFilename in Directory.EnumerateFiles(HostDirectory, "*.dll", SearchOption.TopDirectoryOnly)) - { - if (!referenceFilename.Equals(PluginAssembly.Location, StringComparison.InvariantCultureIgnoreCase)) - { - try - { - Assembly pluginRefAssembly = Assembly.ReflectionOnlyLoadFrom(referenceFilename); - referencedAssemblies[pluginRefAssembly.FullName] = referenceFilename; - } - catch (Exception) { } // Ignore Load Exceptions - } - } - return referencedAssemblies; - } - - private static PluginDefinition InitializePlugin(DiscoDataContext dbContext, Type PluginType, string HostDirectory, Dictionary ReferencedAssemblies = null) - { - if (!typeof(Plugin).IsAssignableFrom(PluginType)) - throw new ArgumentException(string.Format("Plugins [{0}] does not inherit from [IDiscoPlugin]", PluginType.Name)); - - using (Plugin instance = (Plugin)Activator.CreateInstance(PluginType)) - { - try - { - PluginDefinition definition = new PluginDefinition(instance, HostDirectory, ReferencedAssemblies); - - PluginsLog.LogInitializingPlugin(definition); - - instance.Initalize(dbContext); - - return definition; - } - catch (Exception ex) - { - PluginsLog.LogInitializeException(PluginType.Assembly.Location, ex); - return null; - } - } - } - - #endregion - - #region Plugin Referenced Assemblies Resolving - - public static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - { - if (args.RequestingAssembly.Location.StartsWith(PluginPath, StringComparison.InvariantCultureIgnoreCase) && _LoadedPlugins != null) - { - // Try best guess first - PluginDefinition requestingPlugin = _LoadedPlugins.Values.Where(p => p.PluginType.Assembly == args.RequestingAssembly).FirstOrDefault(); - if (requestingPlugin != null) - { - Assembly loadedAssembly = CurrentDomain_AssemblyResolve_ByPlugin(requestingPlugin, args); - if (loadedAssembly != null) - return loadedAssembly; - } - - // Try all Plugin References - foreach (var pluginDef in _LoadedPlugins.Values) - { - Assembly loadedAssembly = CurrentDomain_AssemblyResolve_ByPlugin(pluginDef, args); - if (loadedAssembly != null) - return loadedAssembly; - } - } - return null; - } - private static Assembly CurrentDomain_AssemblyResolve_ByPlugin(PluginDefinition PluginDefinition, ResolveEventArgs args) - { - if (PluginDefinition.PluginReferenceAssemblies != null) - { - string assemblyPath; - if (PluginDefinition.PluginReferenceAssemblies.TryGetValue(args.Name, out assemblyPath)) - { - try - { - Assembly loadedAssembly = Assembly.LoadFile(assemblyPath); - - PluginsLog.LogPluginReferenceAssemblyLoaded(args.Name, assemblyPath, args.RequestingAssembly.FullName); - - return loadedAssembly; - } - catch (Exception ex) - { - PluginsLog.LogPluginException(string.Format("Resolving Plugin Reference Assembly: '{0}' [{1}]; Requested by: '{2}' [{3}]; Disco.Plugins.DiscoPlugins.CurrentDomain_AssemblyResolve()", args.Name, assemblyPath, args.RequestingAssembly.FullName, args.RequestingAssembly.Location), ex); - } - } - } - return null; - } - - #endregion - } -} diff --git a/Disco.Services/_Plugins/PluginsLog.cs b/Disco.Services/_Plugins/PluginsLog.cs deleted file mode 100644 index 11099258..00000000 --- a/Disco.Services/_Plugins/PluginsLog.cs +++ /dev/null @@ -1,259 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Disco.Services.Logging; -using Disco.Services.Logging.Models; -using System.Reflection; - -namespace Disco.Services.Plugins -{ - public class PluginsLog : LogBase - { - private const int _ModuleId = 10; - - public override string ModuleDescription { get { return "Plugins"; } } - public override int ModuleId { get { return _ModuleId; } } - public override string ModuleName { get { return "Plugins"; } } - - public enum EventTypeIds - { - InitializingPlugins = 10, - InitializingPluginAssembly, - InitializedPlugin, - InitializeWarning = 15, - InitializeError, - InitializeException, - InitializeExceptionWithInner, - PluginException = 20, - PluginExceptionWithInner, - PluginReferenceAssemblyLoaded = 50, - PluginConfigurationLoaded = 100, - PluginConfigurationSaved = 104, - PluginWebControllerAccessed = 200 - } - - public static PluginsLog Current - { - get - { - return (PluginsLog)LogContext.LogModules[_ModuleId]; - } - } - private static void Log(EventTypeIds EventTypeId, params object[] Args) - { - Current.Log((int)EventTypeId, Args); - } - - public static void LogInitializingPlugins(string PluginDirectory) - { - Current.Log((int)EventTypeIds.InitializingPlugins, PluginDirectory); - } - public static void LogInitializingPluginAssembly(Assembly PluginAssembly) - { - Current.Log((int)EventTypeIds.InitializingPluginAssembly, PluginAssembly.FullName, PluginAssembly.Location); - } - public static void LogInitializingPlugin(PluginDefinition Definition) - { - Current.Log((int)EventTypeIds.InitializedPlugin, Definition.Id, Definition.Version.ToString(3), Definition.PluginType.Name, Definition.PluginType.Assembly.Location); - } - public static void LogInitializeWarning(string Warning) - { - Current.Log((int)EventTypeIds.InitializeWarning, Warning); - } - public static void LogInitializeError(string Error) - { - Current.Log((int)EventTypeIds.InitializeError, Error); - } - public static void LogPluginReferenceAssemblyLoaded(string AssemblyFullName, string AssemblyPath, string RequestedBy) - { - Current.Log((int)EventTypeIds.PluginReferenceAssemblyLoaded, AssemblyFullName, AssemblyPath, RequestedBy); - } - public static void LogPluginConfigurationLoaded(string PluginId, string UserId) - { - Current.Log((int)EventTypeIds.PluginConfigurationLoaded, PluginId, UserId); - } - public static void LogPluginConfigurationSaved(string PluginId, string UserId) - { - Current.Log((int)EventTypeIds.PluginConfigurationSaved, PluginId, UserId); - } - public static void LogPluginWebControllerAccessed(string PluginId, string PluginAction, string UserId) - { - Current.Log((int)EventTypeIds.PluginWebControllerAccessed, PluginId, PluginAction, UserId); - } - - public static void LogInitializeException(string PluginFilename, Exception ex) - { - if (ex.InnerException != null) - { - Log(EventTypeIds.InitializeExceptionWithInner, PluginFilename, ex.GetType().Name, ex.Message, ex.StackTrace, ex.InnerException.GetType().Name, ex.InnerException.Message, ex.InnerException.StackTrace); - } - else - { - Log(EventTypeIds.InitializeException, PluginFilename, ex.GetType().Name, ex.Message, ex.StackTrace); - } - } - - public static void LogPluginException(string Component, Exception ex) - { - if (ex.InnerException != null) - { - Log(EventTypeIds.PluginExceptionWithInner, Component, ex.GetType().Name, ex.Message, ex.StackTrace, ex.InnerException.GetType().Name, ex.InnerException.Message, ex.InnerException.StackTrace); - } - else - { - Log(EventTypeIds.PluginException, Component, ex.GetType().Name, ex.Message, ex.StackTrace); - } - } - - protected override List LoadEventTypes() - { - return new System.Collections.Generic.List - { - new LogEventType - { - Id = (int)EventTypeIds.InitializingPlugins, - ModuleId = _ModuleId, - Name = "Initializing Plugins", - Format = "Starting plugin discovery and initialization from: {0}", - Severity = (int)LogEventType.Severities.Information, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.InitializingPluginAssembly, - ModuleId = _ModuleId, - Name = "Initializing Plugin Assembly", - Format = "Initializing Plugin Assembly: [{0}] From '{1}'", - Severity = (int)LogEventType.Severities.Information, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.InitializedPlugin, - ModuleId = _ModuleId, - Name = "Initialized Plugin", - Format = "Initialized Plugin: '{0} (v{1})' [{2}] From '{3}'", - Severity = (int)LogEventType.Severities.Information, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.InitializeWarning, - ModuleId = _ModuleId, - Name = "Initialize Warning", - Format = "Initialize Warning: {0}", - Severity = (int)LogEventType.Severities.Warning, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.InitializeError, - ModuleId = _ModuleId, - Name = "Initialize Error", - Format = "Initialize Error: {0}", - Severity = (int)LogEventType.Severities.Error, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.InitializeException, - ModuleId = _ModuleId, - Name = "Initialize Exception", - Format = "Exception: {0}; {1}: {2}; {3}", - Severity = (int)LogEventType.Severities.Error, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.InitializeExceptionWithInner, - ModuleId = _ModuleId, - Name = "Initialize Exception with Inner Exception", - Format = "Exception: {0}; {1}: {2}; {3}; Inner: {4}: {5}; {6}", - Severity = (int)LogEventType.Severities.Error, - UseLive = false, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.PluginException, - ModuleId = _ModuleId, - Name = "Plugin Exception", - Format = "Exception: {0}; {1}: {2}; {3}", - Severity = (int)LogEventType.Severities.Error, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.PluginExceptionWithInner, - ModuleId = _ModuleId, - Name = "Plugin Exception with Inner Exception", - Format = "Exception: {0}; {1}: {2}; {3}; Inner: {4}: {5}; {6}", - Severity = (int)LogEventType.Severities.Error, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.PluginReferenceAssemblyLoaded, - ModuleId = _ModuleId, - Name = "Plugin Reference Assembly Loaded", - Format = "Loaded Plugin Reference Assembly: [{0}] From: '{1}'; Requested by: [{2}]", - Severity = (int)LogEventType.Severities.Information, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.PluginConfigurationLoaded, - ModuleId = _ModuleId, - Name = "Plugin Configuration Loaded", - Format = "Plugin Configuration Loaded: [{0}] by [{1}]", - Severity = (int)LogEventType.Severities.Information, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.PluginConfigurationSaved, - ModuleId = _ModuleId, - Name = "Plugin Configuration Saved", - Format = "Plugin Configuration Saved: [{0}] by [{1}]", - Severity = (int)LogEventType.Severities.Information, - UseLive = true, - UsePersist = true, - UseDisplay = true - }, - new LogEventType - { - Id = (int)EventTypeIds.PluginWebControllerAccessed, - ModuleId = _ModuleId, - Name = "Plugin Web Controller Accessed", - Format = "Plugin Web Controller Accessed: Plugin [{0}], Action [{1}], By [{2}]", - Severity = (int)LogEventType.Severities.Information, - UseLive = true, - UsePersist = true, - UseDisplay = true - } - }; - } - } -} diff --git a/Disco.Services/_Plugins/UnknownPluginException.cs b/Disco.Services/_Plugins/UnknownPluginException.cs deleted file mode 100644 index 1b1da494..00000000 --- a/Disco.Services/_Plugins/UnknownPluginException.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Disco.Services.Plugins -{ - public class UnknownPluginException : Exception - { - private string _pluginRequested; - - public string PluginRequested - { - get - { - return _pluginRequested; - } - } - - public UnknownPluginException(string PluginRequested) - { - this._pluginRequested = PluginRequested; - } - public UnknownPluginException(string PluginRequested, string Message) : base(Message) - { - this._pluginRequested = PluginRequested; - } - - public override string Message - { - get - { - return string.Format("Unknown Plugin Id: [{0}]", _pluginRequested); - } - } - } -}