GIT: perform LF normalization

This commit is contained in:
Gary Sharp
2013-02-28 17:15:46 +11:00
parent 989f08a24d
commit 7d9be5620d
729 changed files with 300734 additions and 300712 deletions
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Data.Repository;
using Disco.Models.Repository;
namespace Disco.Services.Plugins.Features.CertificateProvider
{
[PluginFeatureCategory(DisplayName = "Certificate Providers")]
public abstract class CertificateProviderFeature : PluginFeature
{
// Certificate Plugin Requirements
public abstract string CertificateProviderId { get; }
public abstract Tuple<DeviceCertificate, List<string>> AllocateCertificate(DiscoDataContext dbContext, Device Device);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Data.Repository;
using Disco.Models.Repository;
namespace Disco.Services.Plugins.Features.CertificateProvider
{
[PluginFeatureCategory(DisplayName = "Certificate Providers")]
public abstract class CertificateProviderFeature : PluginFeature
{
// Certificate Plugin Requirements
public abstract string CertificateProviderId { get; }
public abstract Tuple<DeviceCertificate, List<string>> AllocateCertificate(DiscoDataContext dbContext, Device Device);
}
}
@@ -1,304 +1,304 @@
using Disco.Services.Logging;
using Disco.Services.Logging.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Disco.Services.Plugins.Features.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<LogEventType> LoadEventTypes()
{
return new System.Collections.Generic.List<LogEventType>
{
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
}
};
}
}
}
using Disco.Services.Logging;
using Disco.Services.Logging.Models;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Disco.Services.Plugins.Features.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<LogEventType> LoadEventTypes()
{
return new System.Collections.Generic.List<LogEventType>
{
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
}
};
}
}
}
@@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins.Features.InteroperabilityProvider
{
[PluginFeatureCategory(DisplayName = "Interoperability Providers")]
public abstract class InteroperabilityProviderFeature : PluginFeature
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins.Features.InteroperabilityProvider
{
[PluginFeatureCategory(DisplayName = "Interoperability Providers")]
public abstract class InteroperabilityProviderFeature : PluginFeature
{
}
}
@@ -1,13 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins.Features.Other
{
[PluginFeatureCategory(DisplayName = "Other")]
public abstract class OtherFeature : PluginFeature
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins.Features.Other
{
[PluginFeatureCategory(DisplayName = "Other")]
public abstract class OtherFeature : PluginFeature
{
}
}
@@ -1,49 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Disco.Data.Repository;
using Disco.Models.BI.Config;
using Disco.Models.Repository;
namespace Disco.Services.Plugins.Features.WarrantyProvider
{
[PluginFeatureCategory(DisplayName = "Warranty Providers")]
public abstract class WarrantyProviderFeature : PluginFeature
{
// 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<string, string> SubmitJobParseProperties(DiscoDataContext dbContext, FormCollection form, Controller controller, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription);
public abstract Dictionary<string, string> SubmitJobDiscloseInfo(DiscoDataContext dbContext, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary<string, string> WarrantyProviderProperties);
public abstract string SubmitJob(DiscoDataContext dbContext, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary<string, string> 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 PluginFeatureManifest FindPluginFeature(string PluginIdOrWarrantyProviderId)
{
var defs = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature));
var def = defs.FirstOrDefault(d => d.PluginManifest.Id.Equals(PluginIdOrWarrantyProviderId, StringComparison.InvariantCultureIgnoreCase));
if (def != null)
return def;
else
foreach (var d in defs)
{
using (var providerInstance = d.CreateInstance<WarrantyProviderFeature>())
{
if (providerInstance.WarrantyProviderId != null && providerInstance.WarrantyProviderId.Equals(PluginIdOrWarrantyProviderId, StringComparison.InvariantCultureIgnoreCase))
{
return d;
}
}
}
return null;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Disco.Data.Repository;
using Disco.Models.BI.Config;
using Disco.Models.Repository;
namespace Disco.Services.Plugins.Features.WarrantyProvider
{
[PluginFeatureCategory(DisplayName = "Warranty Providers")]
public abstract class WarrantyProviderFeature : PluginFeature
{
// 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<string, string> SubmitJobParseProperties(DiscoDataContext dbContext, FormCollection form, Controller controller, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription);
public abstract Dictionary<string, string> SubmitJobDiscloseInfo(DiscoDataContext dbContext, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary<string, string> WarrantyProviderProperties);
public abstract string SubmitJob(DiscoDataContext dbContext, Job Job, OrganisationAddress Address, User TechUser, string FaultDescription, Dictionary<string, string> 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 PluginFeatureManifest FindPluginFeature(string PluginIdOrWarrantyProviderId)
{
var defs = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature));
var def = defs.FirstOrDefault(d => d.PluginManifest.Id.Equals(PluginIdOrWarrantyProviderId, StringComparison.InvariantCultureIgnoreCase));
if (def != null)
return def;
else
foreach (var d in defs)
{
using (var providerInstance = d.CreateInstance<WarrantyProviderFeature>())
{
if (providerInstance.WarrantyProviderId != null && providerInstance.WarrantyProviderId.Equals(PluginIdOrWarrantyProviderId, StringComparison.InvariantCultureIgnoreCase))
{
return d;
}
}
}
return null;
}
}
}
@@ -1,12 +1,12 @@
using System;
namespace Disco.Services.Plugins.Features.WarrantyProvider
{
public class WarrantyProviderSubmitJobException : Exception
{
public WarrantyProviderSubmitJobException(string Message)
: base(Message)
{
}
}
}
using System;
namespace Disco.Services.Plugins.Features.WarrantyProvider
{
public class WarrantyProviderSubmitJobException : Exception
{
public WarrantyProviderSubmitJobException(string Message)
: base(Message)
{
}
}
}
@@ -1,50 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Services.Plugins
{
public class InvalidFeatureCategoryTypeException : Exception
{
private string _pluginRequested;
private Type _categoryType;
public string PluginRequested
{
get
{
return _pluginRequested;
}
}
public Type CategoryType
{
get
{
return _categoryType;
}
}
public InvalidFeatureCategoryTypeException(Type CategoryType)
: this(CategoryType, null)
{
}
public InvalidFeatureCategoryTypeException(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);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Services.Plugins
{
public class InvalidFeatureCategoryTypeException : Exception
{
private string _pluginRequested;
private Type _categoryType;
public string PluginRequested
{
get
{
return _pluginRequested;
}
}
public Type CategoryType
{
get
{
return _categoryType;
}
}
public InvalidFeatureCategoryTypeException(Type CategoryType)
: this(CategoryType, null)
{
}
public InvalidFeatureCategoryTypeException(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);
}
}
}
}
@@ -1,47 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Disco.Data.Repository;
namespace Disco.Services.Plugins
{
public abstract class PluginConfigurationHandler : IDisposable
{
public PluginManifest Manifest { get; set; }
public abstract PluginConfigurationHandlerGetResponse Get(DiscoDataContext dbContext, Controller controller);
public abstract bool Post(DiscoDataContext dbContext, FormCollection form, Controller controller);
public virtual void Dispose()
{
// Nothing in Base Class
}
protected PluginConfigurationHandlerGetResponse GetResponse(Type ViewType, dynamic ViewModel = null)
{
return new PluginConfigurationHandlerGetResponse(this.Manifest, ViewType, ViewModel);
}
public class PluginConfigurationHandlerGetResponse
{
public PluginManifest Manifest { get; set; }
public Type ViewType { get; set; }
public dynamic ViewModel { get; set; }
public PluginConfigurationHandlerGetResponse(PluginManifest Manifest, Type ViewType, dynamic ViewModel = null)
{
if (ViewType == null)
throw new ArgumentNullException("ViewType");
if (!typeof(WebViewPage).IsAssignableFrom(ViewType))
throw new ArgumentException("The PluginConfigurationHandler ViewType must inherit System.Web.Mvc.WebViewPage", "ViewType");
this.Manifest = Manifest;
this.ViewType = ViewType;
this.ViewModel = ViewModel;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Disco.Data.Repository;
namespace Disco.Services.Plugins
{
public abstract class PluginConfigurationHandler : IDisposable
{
public PluginManifest Manifest { get; set; }
public abstract PluginConfigurationHandlerGetResponse Get(DiscoDataContext dbContext, Controller controller);
public abstract bool Post(DiscoDataContext dbContext, FormCollection form, Controller controller);
public virtual void Dispose()
{
// Nothing in Base Class
}
protected PluginConfigurationHandlerGetResponse GetResponse(Type ViewType, dynamic ViewModel = null)
{
return new PluginConfigurationHandlerGetResponse(this.Manifest, ViewType, ViewModel);
}
public class PluginConfigurationHandlerGetResponse
{
public PluginManifest Manifest { get; set; }
public Type ViewType { get; set; }
public dynamic ViewModel { get; set; }
public PluginConfigurationHandlerGetResponse(PluginManifest Manifest, Type ViewType, dynamic ViewModel = null)
{
if (ViewType == null)
throw new ArgumentNullException("ViewType");
if (!typeof(WebViewPage).IsAssignableFrom(ViewType))
throw new ArgumentException("The PluginConfigurationHandler ViewType must inherit System.Web.Mvc.WebViewPage", "ViewType");
this.Manifest = Manifest;
this.ViewType = ViewType;
this.ViewModel = ViewModel;
}
}
}
}
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class PluginFeatureAttribute : Attribute
{
public string Id { get; set; }
public string Name { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class PluginFeatureAttribute : Attribute
{
public string Id { get; set; }
public string Name { get; set; }
}
}
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class PluginFeatureCategoryAttribute : Attribute
{
public string DisplayName { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Plugins
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public class PluginFeatureCategoryAttribute : Attribute
{
public string DisplayName { get; set; }
}
}
+229 -229
View File
@@ -1,229 +1,229 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Routing;
using RazorGenerator.Mvc;
namespace Disco.Services.Plugins
{
public abstract class PluginWebHandler : IDisposable
{
public PluginManifest Manifest { get; set; }
public Controller HostController { get; set; }
public abstract ActionResult ExecuteAction(string ActionName);
public virtual void Dispose()
{
// Nothing in Base Class
}
#region Action Results
#region Compiled View
private static string[] _viewFileNames = new string[] { "cshtml" };
public ActionResult CompiledView(Type CompiledViewType, object Model, bool UseDiscoLayout)
{
string layoutPath = UseDiscoLayout ? "~/Views/Shared/_Layout.cshtml" : null;
IView v = new PrecompiledMvcView(this.HostController.Request.Path, layoutPath, CompiledViewType, false, _viewFileNames);
if (Model != null)
this.HostController.ViewData.Model = Model;
return new ViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData };
}
public ActionResult CompiledView(Type CompiledViewType, bool UseDiscoLayout)
{
return this.CompiledView(CompiledViewType, null, UseDiscoLayout);
}
public ActionResult CompiledView(Type CompiledViewType, object Model)
{
return this.CompiledView(CompiledViewType, Model, true);
}
public ActionResult CompiledView(Type CompiledViewType)
{
return this.CompiledView(CompiledViewType, false, true);
}
public ActionResult CompiledPartialView(Type PartialCompiledViewType, object Model)
{
IView v = new PrecompiledMvcView(this.HostController.Request.Path, PartialCompiledViewType, false, _viewFileNames);
if (Model != null)
this.HostController.ViewData.Model = Model;
return new PartialViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData };
}
public ActionResult CompiledPartialView(Type PartialCompiledViewType)
{
return this.CompiledView(PartialCompiledViewType, null);
}
#endregion
#region Content
public ActionResult Content(string content, string contentType, Encoding contentEncoding)
{
return new ContentResult { Content = content, ContentType = contentType, ContentEncoding = contentEncoding };
}
public ActionResult Content(string content, string contentType)
{
return this.Content(content, null, null);
}
public ActionResult Content(string content)
{
return this.Content(content, null);
}
#endregion
#region Json
public ActionResult Json(object data, JsonRequestBehavior behavior)
{
return new JsonResult { Data = data, ContentType = null, ContentEncoding = null, JsonRequestBehavior = behavior };
}
#endregion
#region File
public ActionResult File(Stream fileStream, string contentType)
{
return this.File(fileStream, contentType, null);
}
public ActionResult File(Stream fileStream, string contentType, string fileDownloadName)
{
return new FileStreamResult(fileStream, contentType) { FileDownloadName = fileDownloadName };
}
public ActionResult File(byte[] fileContents, string contentType)
{
return this.File(fileContents, contentType, null);
}
public ActionResult File(byte[] fileContents, string contentType, string fileDownloadName)
{
return new FileContentResult(fileContents, contentType) { FileDownloadName = fileDownloadName };
}
#endregion
#region HttpNotFound
public ActionResult HttpNotFound(string statusDescription)
{
return new HttpNotFoundResult(statusDescription);
}
public ActionResult HttpNotFound()
{
return this.HttpNotFound(null);
}
#endregion
#region Redirect
public ActionResult RedirectToScheduledTaskStatus(string SessionId)
{
if (string.IsNullOrEmpty(SessionId))
throw new ArgumentNullException(SessionId);
return this.RedirectToAction("TaskStatus", "Logging", "Config", new { id = SessionId });
}
public ActionResult Redirect(string url)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentNullException("url");
return new RedirectResult(url);
}
public ActionResult RedirectPermanent(string url)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentNullException("url");
return new RedirectResult(url, true);
}
public ActionResult RedirectToPluginAction(string PluginAction)
{
if (string.IsNullOrEmpty(PluginAction))
throw new ArgumentNullException("PluginAction");
var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id, PluginAction = PluginAction });
string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, this.HostController.Request.RequestContext, false);
return new RedirectResult(pluginActionUrl, false);
}
public ActionResult RedirectToPluginResource(string Resource, bool? Download)
{
var resourcePath = this.Manifest.WebResourcePath(Resource);
var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id, res = Resource });
string pluginActionUrl = UrlHelper.GenerateUrl("Plugin_Resources", null, null, routeValues, RouteTable.Routes, this.HostController.Request.RequestContext, false);
pluginActionUrl += string.Format("?v={0}", resourcePath.Item2);
if (Download.HasValue && Download.Value)
{
pluginActionUrl += "&Download=true";
}
return new RedirectResult(pluginActionUrl, false);
}
public ActionResult RedirectToPluginResource(string Resource)
{
return this.RedirectToPluginResource(Resource, null);
}
public ActionResult RedirectToRoute(string routeName, object routeValues)
{
RouteValueDictionary routeValueDictionary;
if (routeValues != null)
routeValueDictionary = new RouteValueDictionary(routeValues);
else
routeValueDictionary = new RouteValueDictionary();
return new RedirectToRouteResult(routeName, routeValueDictionary);
}
public ActionResult RedirectToRoute(string routeName)
{
return this.RedirectToRoute(routeName, null);
}
public ActionResult RedirectToAction(string actionName, string controller, string areaName, object routeValues)
{
RouteValueDictionary routeValueDictionary;
if (routeValues != null)
routeValueDictionary = new RouteValueDictionary(routeValues);
else
routeValueDictionary = new RouteValueDictionary();
routeValueDictionary["action"] = actionName;
routeValueDictionary["controller"] = controller;
if (areaName != null)
routeValueDictionary["area"] = areaName;
return new RedirectToRouteResult(routeValueDictionary);
}
public ActionResult RedirectToAction(string actionName, string controller, string areaName)
{
return this.RedirectToAction(actionName, controller, areaName, null);
}
public ActionResult RedirectToAction(string actionName, string controller, object routeValues)
{
return this.RedirectToAction(actionName, controller, null, routeValues);
}
public ActionResult RedirectToAction(string actionName, string controller)
{
return this.RedirectToAction(actionName, controller, null, null);
}
public ActionResult RedirectToDiscoJob(int jobId)
{
return this.RedirectToAction("Show", "Job", null, new { id = jobId.ToString() });
}
public ActionResult RedirectToDiscoDevice(string DeviceSerialNumber)
{
return this.RedirectToAction("Show", "Device", null, new { id = DeviceSerialNumber });
}
public ActionResult RedirectToDiscoUser(string UserId)
{
return this.RedirectToAction("Show", "User", null, new { id = UserId });
}
#endregion
#endregion
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using System.Web.Routing;
using RazorGenerator.Mvc;
namespace Disco.Services.Plugins
{
public abstract class PluginWebHandler : IDisposable
{
public PluginManifest Manifest { get; set; }
public Controller HostController { get; set; }
public abstract ActionResult ExecuteAction(string ActionName);
public virtual void Dispose()
{
// Nothing in Base Class
}
#region Action Results
#region Compiled View
private static string[] _viewFileNames = new string[] { "cshtml" };
public ActionResult CompiledView(Type CompiledViewType, object Model, bool UseDiscoLayout)
{
string layoutPath = UseDiscoLayout ? "~/Views/Shared/_Layout.cshtml" : null;
IView v = new PrecompiledMvcView(this.HostController.Request.Path, layoutPath, CompiledViewType, false, _viewFileNames);
if (Model != null)
this.HostController.ViewData.Model = Model;
return new ViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData };
}
public ActionResult CompiledView(Type CompiledViewType, bool UseDiscoLayout)
{
return this.CompiledView(CompiledViewType, null, UseDiscoLayout);
}
public ActionResult CompiledView(Type CompiledViewType, object Model)
{
return this.CompiledView(CompiledViewType, Model, true);
}
public ActionResult CompiledView(Type CompiledViewType)
{
return this.CompiledView(CompiledViewType, false, true);
}
public ActionResult CompiledPartialView(Type PartialCompiledViewType, object Model)
{
IView v = new PrecompiledMvcView(this.HostController.Request.Path, PartialCompiledViewType, false, _viewFileNames);
if (Model != null)
this.HostController.ViewData.Model = Model;
return new PartialViewResult { View = v, ViewData = this.HostController.ViewData, TempData = this.HostController.TempData };
}
public ActionResult CompiledPartialView(Type PartialCompiledViewType)
{
return this.CompiledView(PartialCompiledViewType, null);
}
#endregion
#region Content
public ActionResult Content(string content, string contentType, Encoding contentEncoding)
{
return new ContentResult { Content = content, ContentType = contentType, ContentEncoding = contentEncoding };
}
public ActionResult Content(string content, string contentType)
{
return this.Content(content, null, null);
}
public ActionResult Content(string content)
{
return this.Content(content, null);
}
#endregion
#region Json
public ActionResult Json(object data, JsonRequestBehavior behavior)
{
return new JsonResult { Data = data, ContentType = null, ContentEncoding = null, JsonRequestBehavior = behavior };
}
#endregion
#region File
public ActionResult File(Stream fileStream, string contentType)
{
return this.File(fileStream, contentType, null);
}
public ActionResult File(Stream fileStream, string contentType, string fileDownloadName)
{
return new FileStreamResult(fileStream, contentType) { FileDownloadName = fileDownloadName };
}
public ActionResult File(byte[] fileContents, string contentType)
{
return this.File(fileContents, contentType, null);
}
public ActionResult File(byte[] fileContents, string contentType, string fileDownloadName)
{
return new FileContentResult(fileContents, contentType) { FileDownloadName = fileDownloadName };
}
#endregion
#region HttpNotFound
public ActionResult HttpNotFound(string statusDescription)
{
return new HttpNotFoundResult(statusDescription);
}
public ActionResult HttpNotFound()
{
return this.HttpNotFound(null);
}
#endregion
#region Redirect
public ActionResult RedirectToScheduledTaskStatus(string SessionId)
{
if (string.IsNullOrEmpty(SessionId))
throw new ArgumentNullException(SessionId);
return this.RedirectToAction("TaskStatus", "Logging", "Config", new { id = SessionId });
}
public ActionResult Redirect(string url)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentNullException("url");
return new RedirectResult(url);
}
public ActionResult RedirectPermanent(string url)
{
if (string.IsNullOrEmpty(url))
throw new ArgumentNullException("url");
return new RedirectResult(url, true);
}
public ActionResult RedirectToPluginAction(string PluginAction)
{
if (string.IsNullOrEmpty(PluginAction))
throw new ArgumentNullException("PluginAction");
var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id, PluginAction = PluginAction });
string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, this.HostController.Request.RequestContext, false);
return new RedirectResult(pluginActionUrl, false);
}
public ActionResult RedirectToPluginResource(string Resource, bool? Download)
{
var resourcePath = this.Manifest.WebResourcePath(Resource);
var routeValues = new RouteValueDictionary(new { PluginId = this.Manifest.Id, res = Resource });
string pluginActionUrl = UrlHelper.GenerateUrl("Plugin_Resources", null, null, routeValues, RouteTable.Routes, this.HostController.Request.RequestContext, false);
pluginActionUrl += string.Format("?v={0}", resourcePath.Item2);
if (Download.HasValue && Download.Value)
{
pluginActionUrl += "&Download=true";
}
return new RedirectResult(pluginActionUrl, false);
}
public ActionResult RedirectToPluginResource(string Resource)
{
return this.RedirectToPluginResource(Resource, null);
}
public ActionResult RedirectToRoute(string routeName, object routeValues)
{
RouteValueDictionary routeValueDictionary;
if (routeValues != null)
routeValueDictionary = new RouteValueDictionary(routeValues);
else
routeValueDictionary = new RouteValueDictionary();
return new RedirectToRouteResult(routeName, routeValueDictionary);
}
public ActionResult RedirectToRoute(string routeName)
{
return this.RedirectToRoute(routeName, null);
}
public ActionResult RedirectToAction(string actionName, string controller, string areaName, object routeValues)
{
RouteValueDictionary routeValueDictionary;
if (routeValues != null)
routeValueDictionary = new RouteValueDictionary(routeValues);
else
routeValueDictionary = new RouteValueDictionary();
routeValueDictionary["action"] = actionName;
routeValueDictionary["controller"] = controller;
if (areaName != null)
routeValueDictionary["area"] = areaName;
return new RedirectToRouteResult(routeValueDictionary);
}
public ActionResult RedirectToAction(string actionName, string controller, string areaName)
{
return this.RedirectToAction(actionName, controller, areaName, null);
}
public ActionResult RedirectToAction(string actionName, string controller, object routeValues)
{
return this.RedirectToAction(actionName, controller, null, routeValues);
}
public ActionResult RedirectToAction(string actionName, string controller)
{
return this.RedirectToAction(actionName, controller, null, null);
}
public ActionResult RedirectToDiscoJob(int jobId)
{
return this.RedirectToAction("Show", "Job", null, new { id = jobId.ToString() });
}
public ActionResult RedirectToDiscoDevice(string DeviceSerialNumber)
{
return this.RedirectToAction("Show", "Device", null, new { id = DeviceSerialNumber });
}
public ActionResult RedirectToDiscoUser(string UserId)
{
return this.RedirectToAction("Show", "User", null, new { id = UserId });
}
#endregion
#endregion
}
}
@@ -1,121 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace Disco.Services.Plugins
{
public abstract class PluginWebHandlerController : PluginWebHandler
{
public override ActionResult ExecuteAction(string ActionName)
{
var handlerType = this.GetType();
var methodDescriptor = FindControllerMethod(handlerType, ActionName);
if (methodDescriptor == null)
return this.HttpNotFound("Unknown Plugin Method");
var methodParams = BuildMethodParameters(handlerType, methodDescriptor.MethodInfo, ActionName, this.HostController);
return (ActionResult)methodDescriptor.MethodInfo.Invoke(this, methodParams);
}
private static WebHandlerCachedItem FindControllerMethod(Type Handler, string ActionName)
{
var descriptors = CacheWebHandler(Handler);
WebHandlerCachedItem method;
if (descriptors.TryGetValue(ActionName.ToLower(), out method))
return method; // Not Found
else
return null; // Not Found
}
private static object[] BuildMethodParameters(Type Handler, MethodInfo methodInfo, string ActionName, Controller HostController)
{
var methodParams = methodInfo.GetParameters();
var result = new object[methodParams.Length];
for (int i = 0; i < methodParams.Length; i++)
{
var methodParam = methodParams[i];
Type parameterType = methodParam.ParameterType;
IModelBinder modelBinder = ModelBinders.Binders.GetBinder(parameterType);
IValueProvider valueProvider = HostController.ValueProvider;
string parameterName = methodParam.Name;
ModelBindingContext bindingContext = new ModelBindingContext()
{
FallbackToEmptyPrefix = true,
ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, parameterType),
ModelName = parameterName,
ModelState = HostController.ViewData.ModelState,
PropertyFilter = (p) => true,
ValueProvider = valueProvider
};
var parameterValue = modelBinder.BindModel(HostController.ControllerContext, bindingContext);
if (parameterValue == null && methodParam.HasDefaultValue)
parameterValue = methodParam.DefaultValue;
result[i] = parameterValue;
//var paramInstance = Activator.CreateInstance(methodParam.ParameterType);
//IModelBinder binder = ModelBinders.Binders.GetBinder(methodParam.ParameterType);
//ModelBindingContext bindingContext = new ModelBindingContext
//{
// ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => paramInstance, methodParam.ParameterType),
// ModelName = methodParam.Name,
// ModelState = HostController.ModelState,
// PropertyFilter = (p) => true,
// ValueProvider = HostController.ValueProvider
//};
//binder.BindModel(HostController.ControllerContext, bindingContext);
//if (methodParam.HasDefaultValue && paramInstance == null)
// paramInstance = methodParam.DefaultValue;
//result[i] = paramInstance;
}
return result;
}
#region Method Cache
private static Dictionary<Type, Dictionary<string, WebHandlerCachedItem>> WebHandlerCachedItems = new Dictionary<Type, Dictionary<string, WebHandlerCachedItem>>();
private static Dictionary<string, WebHandlerCachedItem> CacheWebHandler(Type Handler)
{
Dictionary<string, WebHandlerCachedItem> result;
if (!WebHandlerCachedItems.TryGetValue(Handler, out result))
{
// Cache Miss
result = new Dictionary<string, WebHandlerCachedItem>();
var methods = Array.FindAll<MethodInfo>(Handler.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), mi => { return !mi.IsSpecialName && typeof(ActionResult).IsAssignableFrom(mi.ReturnType); });
foreach (var method in methods)
{
var item = new WebHandlerCachedItem()
{
Method = method.Name,
MethodInfo = method
};
result.Add(item.Method.ToLower(), item);
}
WebHandlerCachedItems[Handler] = result;
}
return result;
}
private class WebHandlerCachedItem
{
public string Method { get; set; }
public MethodInfo MethodInfo { get; set; }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
namespace Disco.Services.Plugins
{
public abstract class PluginWebHandlerController : PluginWebHandler
{
public override ActionResult ExecuteAction(string ActionName)
{
var handlerType = this.GetType();
var methodDescriptor = FindControllerMethod(handlerType, ActionName);
if (methodDescriptor == null)
return this.HttpNotFound("Unknown Plugin Method");
var methodParams = BuildMethodParameters(handlerType, methodDescriptor.MethodInfo, ActionName, this.HostController);
return (ActionResult)methodDescriptor.MethodInfo.Invoke(this, methodParams);
}
private static WebHandlerCachedItem FindControllerMethod(Type Handler, string ActionName)
{
var descriptors = CacheWebHandler(Handler);
WebHandlerCachedItem method;
if (descriptors.TryGetValue(ActionName.ToLower(), out method))
return method; // Not Found
else
return null; // Not Found
}
private static object[] BuildMethodParameters(Type Handler, MethodInfo methodInfo, string ActionName, Controller HostController)
{
var methodParams = methodInfo.GetParameters();
var result = new object[methodParams.Length];
for (int i = 0; i < methodParams.Length; i++)
{
var methodParam = methodParams[i];
Type parameterType = methodParam.ParameterType;
IModelBinder modelBinder = ModelBinders.Binders.GetBinder(parameterType);
IValueProvider valueProvider = HostController.ValueProvider;
string parameterName = methodParam.Name;
ModelBindingContext bindingContext = new ModelBindingContext()
{
FallbackToEmptyPrefix = true,
ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, parameterType),
ModelName = parameterName,
ModelState = HostController.ViewData.ModelState,
PropertyFilter = (p) => true,
ValueProvider = valueProvider
};
var parameterValue = modelBinder.BindModel(HostController.ControllerContext, bindingContext);
if (parameterValue == null && methodParam.HasDefaultValue)
parameterValue = methodParam.DefaultValue;
result[i] = parameterValue;
//var paramInstance = Activator.CreateInstance(methodParam.ParameterType);
//IModelBinder binder = ModelBinders.Binders.GetBinder(methodParam.ParameterType);
//ModelBindingContext bindingContext = new ModelBindingContext
//{
// ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => paramInstance, methodParam.ParameterType),
// ModelName = methodParam.Name,
// ModelState = HostController.ModelState,
// PropertyFilter = (p) => true,
// ValueProvider = HostController.ValueProvider
//};
//binder.BindModel(HostController.ControllerContext, bindingContext);
//if (methodParam.HasDefaultValue && paramInstance == null)
// paramInstance = methodParam.DefaultValue;
//result[i] = paramInstance;
}
return result;
}
#region Method Cache
private static Dictionary<Type, Dictionary<string, WebHandlerCachedItem>> WebHandlerCachedItems = new Dictionary<Type, Dictionary<string, WebHandlerCachedItem>>();
private static Dictionary<string, WebHandlerCachedItem> CacheWebHandler(Type Handler)
{
Dictionary<string, WebHandlerCachedItem> result;
if (!WebHandlerCachedItems.TryGetValue(Handler, out result))
{
// Cache Miss
result = new Dictionary<string, WebHandlerCachedItem>();
var methods = Array.FindAll<MethodInfo>(Handler.GetMethods(BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly), mi => { return !mi.IsSpecialName && typeof(ActionResult).IsAssignableFrom(mi.ReturnType); });
foreach (var method in methods)
{
var item = new WebHandlerCachedItem()
{
Method = method.Name,
MethodInfo = method
};
result.Add(item.Method.ToLower(), item);
}
WebHandlerCachedItems[Handler] = result;
}
return result;
}
private class WebHandlerCachedItem
{
public string Method { get; set; }
public MethodInfo MethodInfo { get; set; }
}
#endregion
}
}
@@ -1,37 +1,37 @@
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);
}
}
}
}
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);
}
}
}
}