Features with no code should be loaded successfully

Simply return a feature with no exported types instead of failing. The system
is currently built with the assumption that if an extension is active,
then any of its feature can be activated/loaded.

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-10-23 13:42:40 -07:00
parent 0616035d5d
commit 10e9991f5c

View File

@@ -92,8 +92,14 @@ namespace Orchard.Environment.Extensions {
throw new ArgumentException(T("Feature {0} was not found in any of the installed extensions", featureName).ToString());
var extension = LoadedExtensions().Where(x => x.Descriptor.Name == extensionName).FirstOrDefault();
if (extension == null)
throw new InvalidOperationException(T("Extension {0} is not active", extensionName).ToString());
if (extension == null) {
// If the feature could not be compiled for some reason,
// return a "null" feature, i.e. a feature with no exported types.
return new Feature {
Descriptor = featureDescriptor,
ExportedTypes = Enumerable.Empty<Type>()
};
}
var extensionTypes = extension.ExportedTypes.Where(t => t.IsClass && !t.IsAbstract);
var featureTypes = new List<Type>();