Update: Plugin Framework

This commit is contained in:
Gary Sharp
2013-03-04 20:55:14 +11:00
parent 9b80fd743b
commit c205386bcf
18 changed files with 172 additions and 77 deletions
@@ -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,