Update: Plugin Framework
This commit is contained in:
@@ -24,6 +24,10 @@ namespace Disco.Services.Plugins.Features.UIExtension
|
||||
{
|
||||
return new LiteralResult(this.Manifest, null);
|
||||
}
|
||||
protected LiteralResult ScriptInline(string JavaScriptContent)
|
||||
{
|
||||
return new LiteralResult(this.Manifest, string.Concat("<script type=\"text/javascript\">\n//<!--\n", JavaScriptContent, "\n//-->\n</script>"));
|
||||
}
|
||||
protected PluginResourceScriptResult ScriptResource(string Resource, bool PlaceInPageHead)
|
||||
{
|
||||
return new PluginResourceScriptResult(this.Manifest, Resource, PlaceInPageHead);
|
||||
|
||||
@@ -11,5 +11,6 @@ namespace Disco.Services.Plugins
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool PrimaryFeature { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace Disco.Services.Plugins
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string TypeName { get; set; }
|
||||
|
||||
public bool PrimaryFeature { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
private string CategoryTypeName { get; set; }
|
||||
|
||||
@@ -77,6 +78,7 @@ namespace Disco.Services.Plugins
|
||||
|
||||
var featureId = featureAttribute.Id;
|
||||
var featureName = featureAttribute.Name;
|
||||
var featurePrimary = featureAttribute.PrimaryFeature;
|
||||
|
||||
// Determine Feature Category
|
||||
var featureCategoryType = featureType.BaseType;
|
||||
@@ -84,6 +86,10 @@ namespace Disco.Services.Plugins
|
||||
if (featureCategoryType == null)
|
||||
throw new ArgumentException(string.Format("Plugin Feature found [{0}], but has no Base Type to determine its Category", featureType.Name), "featureType");
|
||||
|
||||
// Handle Generic-Type Features (Only use base-feature, not generic parameters)
|
||||
if (featureCategoryType.IsGenericType)
|
||||
featureCategoryType = featureCategoryType.GetGenericTypeDefinition();
|
||||
|
||||
if (featureCategoryType == typeof(PluginFeature) || !typeof(PluginFeature).IsAssignableFrom(featureCategoryType))
|
||||
throw new ArgumentException(string.Format("Plugin Feature found [{0}], but its Base Type is not a valid Feature Category Type (Base Feature or not assignable)", featureType.Name), "featureType");
|
||||
|
||||
@@ -97,6 +103,7 @@ namespace Disco.Services.Plugins
|
||||
PluginManifest = pluginManifest,
|
||||
Id = featureId,
|
||||
Name = featureName,
|
||||
PrimaryFeature = featurePrimary,
|
||||
Type = featureType,
|
||||
TypeName = featureType.FullName,
|
||||
CategoryType = featureCategoryType,
|
||||
|
||||
@@ -414,5 +414,31 @@ namespace Disco.Services.Plugins
|
||||
|
||||
return new Tuple<string, string>(resourcePath, resourceHash.Item1);
|
||||
}
|
||||
|
||||
public void LogException(Exception PluginException)
|
||||
{
|
||||
PluginsLog.LogPluginException(this.ToString(), PluginException);
|
||||
}
|
||||
public void LogWarning(string Message)
|
||||
{
|
||||
LogWarning(Message, null);
|
||||
}
|
||||
public void LogWarning(string MessageFormat, params object[] Args)
|
||||
{
|
||||
PluginsLog.LogPluginWarning(this, string.Format(MessageFormat, Args), Args);
|
||||
}
|
||||
public void LogMessage(string Message)
|
||||
{
|
||||
LogMessage(Message, null);
|
||||
}
|
||||
public void LogMessage(string MessageFormat, params object[] Args)
|
||||
{
|
||||
PluginsLog.LogPluginMessage(this, string.Format(MessageFormat, Args), Args);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("{0} [{1} v{2}]", this.Name, this.Id, this.VersionFormatted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace Disco.Services.Plugins
|
||||
InitializeExceptionWithInner,
|
||||
PluginException = 20,
|
||||
PluginExceptionWithInner,
|
||||
PluginWarning = 30,
|
||||
PluginMessage = 40,
|
||||
PluginReferenceAssemblyLoaded = 50,
|
||||
PluginConfigurationLoaded = 100,
|
||||
PluginConfigurationSaved = 104,
|
||||
@@ -142,6 +144,39 @@ namespace Disco.Services.Plugins
|
||||
Log(EventTypeIds.PluginException, Component, ex.GetType().Name, ex.Message, ex.StackTrace);
|
||||
}
|
||||
}
|
||||
public static void LogPluginWarning(PluginManifest Manifest, string Message, params object[] ExportData)
|
||||
{
|
||||
LogPluginWarningOrMessage(EventTypeIds.PluginWarning, Manifest, Message, ExportData);
|
||||
}
|
||||
public static void LogPluginMessage(PluginManifest Manifest, string Message, params object[] ExportData)
|
||||
{
|
||||
LogPluginWarningOrMessage(EventTypeIds.PluginMessage, Manifest, Message, ExportData);
|
||||
}
|
||||
private static void LogPluginWarningOrMessage(EventTypeIds WarningOrMessage, PluginManifest Manifest, string Message, object[] ExportData)
|
||||
{
|
||||
if (WarningOrMessage != EventTypeIds.PluginMessage && WarningOrMessage != EventTypeIds.PluginWarning)
|
||||
throw new ArgumentException("Only PluginMessage/PluginWarning is allowed", "WarningOrMessage");
|
||||
|
||||
object[] LogData;
|
||||
|
||||
if (ExportData == null || ExportData.Length == 0)
|
||||
{
|
||||
LogData = new object[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
LogData = new object[4 + ExportData.Length];
|
||||
for (int i = 0; i < ExportData.Length; i++)
|
||||
LogData[4 + i] = ExportData[i];
|
||||
}
|
||||
|
||||
LogData[0] = Manifest.Name;
|
||||
LogData[1] = Manifest.Id;
|
||||
LogData[2] = Manifest.VersionFormatted;
|
||||
LogData[3] = Message;
|
||||
|
||||
Log(WarningOrMessage, LogData);
|
||||
}
|
||||
|
||||
protected override List<Logging.Models.LogEventType> LoadEventTypes()
|
||||
{
|
||||
@@ -257,6 +292,28 @@ namespace Disco.Services.Plugins
|
||||
UsePersist = true,
|
||||
UseDisplay = true
|
||||
},
|
||||
new LogEventType
|
||||
{
|
||||
Id = (int)EventTypeIds.PluginWarning,
|
||||
ModuleId = _ModuleId,
|
||||
Name = "Plugin Warning",
|
||||
Format = "{0} [{1} v{2}]: {3}",
|
||||
Severity = (int)LogEventType.Severities.Warning,
|
||||
UseLive = true,
|
||||
UsePersist = true,
|
||||
UseDisplay = true
|
||||
},
|
||||
new LogEventType
|
||||
{
|
||||
Id = (int)EventTypeIds.PluginMessage,
|
||||
ModuleId = _ModuleId,
|
||||
Name = "Plugin Message",
|
||||
Format = "{0} [{1} v{2}]: {3}",
|
||||
Severity = (int)LogEventType.Severities.Information,
|
||||
UseLive = true,
|
||||
UsePersist = true,
|
||||
UseDisplay = true
|
||||
},
|
||||
new LogEventType
|
||||
{
|
||||
Id = (int)EventTypeIds.PluginReferenceAssemblyLoaded,
|
||||
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.2.0225.1951")]
|
||||
[assembly: AssemblyFileVersion("1.2.0225.1951")]
|
||||
[assembly: AssemblyVersion("1.2.0304.2046")]
|
||||
[assembly: AssemblyFileVersion("1.2.0304.2046")]
|
||||
|
||||
Reference in New Issue
Block a user