mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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))));
|
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
|
name: Settings
|
||||||
antiforgery: enabled
|
antiforgery: enabled
|
||||||
features:
|
|
||||||
Settings:
|
|
||||||
description: Site configuration support
|
|
||||||
|
|||||||
@@ -1,5 +1,2 @@
|
|||||||
name: Setup
|
name: Setup
|
||||||
antiforgery: enabled
|
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) {
|
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(Mapping features, ExtensionDescriptor extensionDescriptor) {
|
||||||
List<FeatureDescriptor> featureDescriptors = new List<FeatureDescriptor>();
|
List<FeatureDescriptor> featureDescriptors = new List<FeatureDescriptor>();
|
||||||
if (features == null) return featureDescriptors;
|
if (features != null) {
|
||||||
foreach (var entity in features.Entities) {
|
foreach (var entity in features.Entities) {
|
||||||
FeatureDescriptor featureDescriptor = new FeatureDescriptor {
|
FeatureDescriptor featureDescriptor = new FeatureDescriptor {
|
||||||
Extension = extensionDescriptor,
|
Extension = extensionDescriptor,
|
||||||
Name = entity.Key.ToString(),
|
Name = entity.Key.ToString(),
|
||||||
};
|
};
|
||||||
Mapping featureMapping = (Mapping)entity.Value;
|
Mapping featureMapping = (Mapping)entity.Value;
|
||||||
foreach (var featureEntity in featureMapping.Entities) {
|
foreach (var featureEntity in featureMapping.Entities) {
|
||||||
if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) {
|
if (String.Equals(featureEntity.Key.ToString(), "description", StringComparison.OrdinalIgnoreCase)) {
|
||||||
featureDescriptor.Description = featureEntity.Value.ToString();
|
featureDescriptor.Description = featureEntity.Value.ToString();
|
||||||
}
|
}
|
||||||
else if (String.Equals(featureEntity.Key.ToString(), "category", StringComparison.OrdinalIgnoreCase)) {
|
else if (String.Equals(featureEntity.Key.ToString(), "category", StringComparison.OrdinalIgnoreCase)) {
|
||||||
featureDescriptor.Category = featureEntity.Value.ToString();
|
featureDescriptor.Category = featureEntity.Value.ToString();
|
||||||
}
|
}
|
||||||
else if (String.Equals(featureEntity.Key.ToString(), "dependencies", StringComparison.OrdinalIgnoreCase)) {
|
else if (String.Equals(featureEntity.Key.ToString(), "dependencies", StringComparison.OrdinalIgnoreCase)) {
|
||||||
featureDescriptor.Dependencies = ParseFeatureDependenciesEntry(featureEntity.Value.ToString());
|
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;
|
return featureDescriptors;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user