mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Creating feature for extension name implicitly
Supports existing module.txt file format Reduces the size of a minimalistic descriptor file --HG-- branch : dev
This commit is contained in:
@@ -295,5 +295,23 @@ features:
|
||||
Assert.That((type == typeof(Alpha) || (type == typeof(Beta))));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ModuleNameIsIntroducedAsFeatureImplicitly() {
|
||||
var extensionLoader = new StubLoaders();
|
||||
var extensionFolder = new StubFolders();
|
||||
|
||||
extensionFolder.Manifests.Add("Minimalistic", @"
|
||||
name: Minimalistic
|
||||
version: 1.0.3
|
||||
orchardversion: 1
|
||||
");
|
||||
|
||||
ExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader });
|
||||
var minimalisticModule = extensionManager.AvailableExtensions().Single(x => x.Name == "Minimalistic");
|
||||
|
||||
Assert.That(minimalisticModule.Features.Count(), Is.EqualTo(1));
|
||||
Assert.That(minimalisticModule.Features.Single().Name, Is.EqualTo("Minimalistic"));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,2 @@
|
||||
name: Settings
|
||||
antiforgery: enabled
|
||||
features:
|
||||
Settings:
|
||||
description: Site configuration support
|
||||
|
@@ -1,5 +1,2 @@
|
||||
name: Setup
|
||||
antiforgery: enabled
|
||||
features:
|
||||
Orchard.Setup:
|
||||
description: Components needed to initialize a new instance or tenant
|
||||
|
@@ -88,26 +88,33 @@ namespace Orchard.Environment.Extensions {
|
||||
|
||||
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(Mapping features, ExtensionDescriptor extensionDescriptor) {
|
||||
List<FeatureDescriptor> featureDescriptors = new List<FeatureDescriptor>();
|
||||
if (features == null) return featureDescriptors;
|
||||
foreach (var entity in features.Entities) {
|
||||
FeatureDescriptor featureDescriptor = new FeatureDescriptor {
|
||||
Extension = extensionDescriptor,
|
||||
Name = entity.Key.ToString(),
|
||||
};
|
||||
Mapping featureMapping = (Mapping)entity.Value;
|
||||
foreach (var featureEntity in featureMapping.Entities) {
|
||||
if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Description = featureEntity.Value.ToString();
|
||||
}
|
||||
else if (String.Equals(featureEntity.Key.ToString(), "category", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Category = featureEntity.Value.ToString();
|
||||
}
|
||||
else if (String.Equals(featureEntity.Key.ToString(), "dependencies", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Dependencies = ParseFeatureDependenciesEntry(featureEntity.Value.ToString());
|
||||
if (features != null) {
|
||||
foreach (var entity in features.Entities) {
|
||||
FeatureDescriptor featureDescriptor = new FeatureDescriptor {
|
||||
Extension = extensionDescriptor,
|
||||
Name = entity.Key.ToString(),
|
||||
};
|
||||
Mapping featureMapping = (Mapping)entity.Value;
|
||||
foreach (var featureEntity in featureMapping.Entities) {
|
||||
if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Description = featureEntity.Value.ToString();
|
||||
}
|
||||
else if (String.Equals(featureEntity.Key.ToString(), "category", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Category = featureEntity.Value.ToString();
|
||||
}
|
||||
else if (String.Equals(featureEntity.Key.ToString(), "dependencies", StringComparison.OrdinalIgnoreCase)) {
|
||||
featureDescriptor.Dependencies = ParseFeatureDependenciesEntry(featureEntity.Value.ToString());
|
||||
}
|
||||
}
|
||||
featureDescriptors.Add(featureDescriptor);
|
||||
}
|
||||
featureDescriptors.Add(featureDescriptor);
|
||||
|
||||
}
|
||||
if (!featureDescriptors.Any(fd => fd.Name == extensionDescriptor.Name)) {
|
||||
featureDescriptors.Add(new FeatureDescriptor {
|
||||
Name = extensionDescriptor.Name,
|
||||
Dependencies = new string[0],
|
||||
Extension = extensionDescriptor,
|
||||
});
|
||||
}
|
||||
return featureDescriptors;
|
||||
}
|
||||
|
Reference in New Issue
Block a user