Extending manifest parser to support flatenned default feature.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2011-03-16 08:55:07 -07:00
parent 7d44329f5a
commit 173af2bcbe
49 changed files with 260 additions and 258 deletions

View File

@@ -169,6 +169,26 @@ Features:
Assert.That(descriptor.Features.First().Description, Is.EqualTo("My super wiki module for Orchard."));
}
[Test]
public void ExtensionDescriptorsShouldBeParsedForMinimalModuleTxtWithSimpleFormat() {
_folders.Manifests.Add("SuperWiki", @"
Name: SuperWiki
Version: 1.0.3
OrchardVersion: 1
Description: My super wiki module for Orchard.
");
var descriptor = _manager.AvailableExtensions().Single();
Assert.That(descriptor.Id, Is.EqualTo("SuperWiki"));
Assert.That(descriptor.Version, Is.EqualTo("1.0.3"));
Assert.That(descriptor.OrchardVersion, Is.EqualTo("1"));
Assert.That(descriptor.Features.Count(), Is.EqualTo(1));
Assert.That(descriptor.Features.First().Id, Is.EqualTo("SuperWiki"));
Assert.That(descriptor.Features.First().Extension.Id, Is.EqualTo("SuperWiki"));
Assert.That(descriptor.Features.First().Description, Is.EqualTo("My super wiki module for Orchard."));
}
[Test]
public void ExtensionDescriptorsShouldBeParsedForCompleteModuleTxt() {
@@ -250,6 +270,84 @@ Features:
}
}
[Test]
public void ExtensionDescriptorsShouldBeParsedForCompleteModuleTxtWithSimpleFormat() {
_folders.Manifests.Add("AnotherWiki", @"
Name: AnotherWiki
Author: Coder Notaprogrammer
Website: http://anotherwiki.codeplex.com
Version: 1.2.3
OrchardVersion: 1
Description: Module Description
FeatureDescription: My super wiki module for Orchard.
Dependencies: Versioning, Search
Category: Content types
Features:
AnotherWiki Editor:
Description: A rich editor for wiki contents.
Dependencies: TinyMCE, AnotherWiki
Category: Input methods
AnotherWiki DistributionList:
Description: Sends e-mail alerts when wiki contents gets published.
Dependencies: AnotherWiki, Email Subscriptions
Category: Email
AnotherWiki Captcha:
Description: Kills spam. Or makes it zombie-like.
Dependencies: AnotherWiki, reCaptcha
Category: Spam
");
var descriptor = _manager.AvailableExtensions().Single();
Assert.That(descriptor.Id, Is.EqualTo("AnotherWiki"));
Assert.That(descriptor.Name, Is.EqualTo("AnotherWiki"));
Assert.That(descriptor.Author, Is.EqualTo("Coder Notaprogrammer"));
Assert.That(descriptor.WebSite, Is.EqualTo("http://anotherwiki.codeplex.com"));
Assert.That(descriptor.Version, Is.EqualTo("1.2.3"));
Assert.That(descriptor.OrchardVersion, Is.EqualTo("1"));
Assert.That(descriptor.Description, Is.EqualTo("Module Description"));
Assert.That(descriptor.Features.Count(), Is.EqualTo(4));
foreach (var featureDescriptor in descriptor.Features) {
switch (featureDescriptor.Id) {
case "AnotherWiki":
Assert.That(featureDescriptor.Extension, Is.SameAs(descriptor));
Assert.That(featureDescriptor.Description, Is.EqualTo("My super wiki module for Orchard."));
Assert.That(featureDescriptor.Category, Is.EqualTo("Content types"));
Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2));
Assert.That(featureDescriptor.Dependencies.Contains("Versioning"));
Assert.That(featureDescriptor.Dependencies.Contains("Search"));
break;
case "AnotherWiki Editor":
Assert.That(featureDescriptor.Extension, Is.SameAs(descriptor));
Assert.That(featureDescriptor.Description, Is.EqualTo("A rich editor for wiki contents."));
Assert.That(featureDescriptor.Category, Is.EqualTo("Input methods"));
Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2));
Assert.That(featureDescriptor.Dependencies.Contains("TinyMCE"));
Assert.That(featureDescriptor.Dependencies.Contains("AnotherWiki"));
break;
case "AnotherWiki DistributionList":
Assert.That(featureDescriptor.Extension, Is.SameAs(descriptor));
Assert.That(featureDescriptor.Description, Is.EqualTo("Sends e-mail alerts when wiki contents gets published."));
Assert.That(featureDescriptor.Category, Is.EqualTo("Email"));
Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2));
Assert.That(featureDescriptor.Dependencies.Contains("AnotherWiki"));
Assert.That(featureDescriptor.Dependencies.Contains("Email Subscriptions"));
break;
case "AnotherWiki Captcha":
Assert.That(featureDescriptor.Extension, Is.SameAs(descriptor));
Assert.That(featureDescriptor.Description, Is.EqualTo("Kills spam. Or makes it zombie-like."));
Assert.That(featureDescriptor.Category, Is.EqualTo("Spam"));
Assert.That(featureDescriptor.Dependencies.Count(), Is.EqualTo(2));
Assert.That(featureDescriptor.Dependencies.Contains("AnotherWiki"));
Assert.That(featureDescriptor.Dependencies.Contains("reCaptcha"));
break;
default:
Assert.Fail("Features not parsed correctly");
break;
}
}
}
[Test]
public void ExtensionManagerShouldLoadFeatures() {
var extensionLoader = new StubLoaders();

View File

@@ -5,8 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The common module introduces content parts that are going to be used by most content types (common, body and routable).
Features:
Common:
Description: Core content parts.
FeatureDescription: Core content parts.
Dependencies: Settings
Category: Core

View File

@@ -5,8 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The containers module introduces container and containable behaviors for content items.
Features:
Containers:
Description: Container and containable parts to enable parent-child relationships between content items.
FeatureDescription: Container and containable parts to enable parent-child relationships between content items.
Dependencies: Contents, Routable
Category: Content

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The contents module enables the creation of custom content types.
Features:
Contents:
Description: Default custom content type definition, creation and management.
FeatureDescription: Default custom content type definition, creation and management.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The dashboard module is providing the dashboard screen of the admininstration UI of the application.
Features:
Dashboard:
Description: Standard admin dashboard.
FeatureDescription: Standard admin dashboard.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Feeds module is providing RSS feeds to content items.
Features:
Feeds:
Description: RSS feeds for content items.
FeatureDescription: RSS feeds for content items.
Category: Syndication

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The HomePage module enables the promotion of a content item or container to be the home page of the site.
Features:
HomePage:
Description: Standard site home page that allows a specified content type or container to *be* the home page.
FeatureDescription: Standard site home page that allows a specified content type or container to *be* the home page.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The navigation module creates and manages a simple navigation menu for the front-end of the application and allows you to add content items to the admin menu.
Features:
Navigation:
Description: Menu management.
FeatureDescription: Menu management.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The dashboard module is providing the reports screen of the application.
Features:
Reports:
Description: Reports management.
FeatureDescription: Reports management.
Category: Core

View File

@@ -5,8 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The routable module enables content items to be accessed through a friendly human-readable URL.
Features:
Routable:
Description: Routable content part.
FeatureDescription: Routable content part.
Dependencies: Settings
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The scheduling module enables background task scheduling.
Features:
Scheduling:
Description: Scheduled background tasks.
FeatureDescription: Scheduled background tasks.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The settings module creates site settings that other modules can contribute to.
Features:
Settings:
Description: Site settings.
FeatureDescription: Site settings.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The shapes module contains core shape templates and display hooks.
Features:
Shapes:
Description: Core shape templates and display hooks.
FeatureDescription: Core shape templates and display hooks.
Category: Core

View File

@@ -5,7 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The XmlRpc module enables creation of contents from client applications such as LiveWriter.
Features:
XmlRpc:
Description: XML-RPC opt-in implementation.
FeatureDescription: XML-RPC opt-in implementation.
Category: Content Publishing

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Lucene module enables the site to be indexed using Lucene.NET. The index generated by this module can then be used by the search module to provide an integrated full-text search experience to a web site.
Features:
Lucene:
Name: Lucene
Description: Lucene indexing services.
FeatureDescription: Lucene indexing services.
Category: Search

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The ArchiveLater module introduces scheduled archiving functionality.
Features:
Orchard.ArchiveLater:
Name: Archive Later
Description: Scheduled archiving.
FeatureDescription: Scheduled archiving.
Category: Content
Dependencies: Common, Scheduling, Orchard.jQuery

View File

@@ -5,12 +5,10 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Orchard Blogs module is implementing basic blogging features.
Features:
Orchard.Blogs:
Name: Blogs
Description: A simple web log.
FeatureDescription: A simple web log.
Dependencies: Shapes, Common, Routable, Feeds, Navigation, Orchard.Widgets, Orchard.jQuery, Orchard.PublishLater
Category: Content
Features:
Orchard.Blogs.RemotePublishing:
Name: Remote Blog Publishing
Description: Blog easier using a dedicated MetaWeblogAPI-compatible publishing tool.

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: Tools to create Orchard components.
Features:
Orchard.CodeGeneration:
Name: Code Generation
Description: Tools to create Orchard components.
FeatureDescription: Tools to create Orchard components.
Category: Developer

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The comments system implemented by this module can be applied to arbitrary Orchard content types, such as blogs and pages. It includes comment validation and spam protection through the Akismet service.
Features:
Orchard.Comments:
Name: Comments
Description: Standard content item comments.
FeatureDescription: Standard content item comments.
Dependencies: Settings
Category: Social

View File

@@ -4,9 +4,6 @@ Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Features:
Orchard.ContentTypes:
Name: Content Types
Description: ContentTypes modules enables the creation and alteration of content types not based on code.
Dependencies: Contents
Category: Content

View File

@@ -5,12 +5,10 @@ Website: http://orchardproject.net
Version: 1.0
OrchardVersion: 1.0
Description: Contains designer tools to ease the Themes development process
Features:
Orchard.DesignerTools:
Name: Shape Tracing
Category: Designer
Description: Displays all currently displayed shapes and some information to customize them
FeatureDescription: Displays all currently displayed shapes and some information to customize them
Dependencies: Orchard.jQuery
Features:
UrlAlternates:
Name: Url Alternates
Category: Designer

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Email Messaging module adds Email sending functionalities.
Features:
Orchard.Email:
Name: Email
Description: Email Messaging services.
FeatureDescription: Email Messaging services.
Category: Messaging
Dependencies: Orchard.Messaging

View File

@@ -5,11 +5,8 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: An assortment of debugging tools.
Features:
Orchard.Experimental:
Name: Experimental
Description: An assortment of debugging tools.
Category: Developer
Features:
Profiling:
Name: Profiling
Description: Tools to help profile Orchard.

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: Provides content item data import and export capability.
Features:
Orchard.ImportExport:
Name: Import Export
Description: Imports and exports content item data
FeatureDescription: Imports and exports content item data
Category: Content

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Indexing module enables the site to be indexed. The index generated by this module can then be used by the search module to provide an integrated full-text search experience to a web site.
Features:
Orchard.Indexing:
Name: Indexing
Description: Indexing infrastructure. Requires an index implementation like the Lucene module.
FeatureDescription: Indexing infrastructure. Requires an index implementation like the Lucene module.
Category: Search

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: Introduces a preconfigured container-enabled content type.
Features:
Orchard.Lists:
Name: Lists
Description: A basic container-enabled content type.
FeatureDescription: A basic container-enabled content type.
Dependencies: Contents, Containers, Navigation
Category: Content

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The localization module enables the localization of content items.
Features:
Orchard.Localization:
Name: Localization
Description: Localize content items.
FeatureDescription: Localize content items.
Dependencies: Settings
Category: Content

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The media module offer basic media management features. It currently only supports image files. Storage goes into the current Orchard file system, which can be the server's physical file system or Azure blob storage.
Features:
Orchard.Media:
Name: Media
Description: File system based media upload, storage and management.
FeatureDescription: File system based media upload, storage and management.
Category: Media

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0
OrchardVersion: 1.0
Description: Description for the module
Features:
Orchard.MediaPicker:
Name: MediaPicker
Dependencies: Orchard.Media, Orchard.jQuery
Description: UI for browsing for, uploading, or selecting an image for an HTML editor.
FeatureDescription: UI for browsing for, uploading, or selecting an image for an HTML editor.
Category: Input Editor

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Messaging module adds messaging functionalities.
Features:
Orchard.Messaging:
Name: Messaging
Description: Messaging services.
FeatureDescription: Messaging services.
Category: Messaging
Dependencies: Settings

View File

@@ -5,11 +5,9 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: Data migration commands.
Features:
Orchard.Migrations:
Name: Migrations
Description: Data migration commands.
FeatureDescription: Data migration commands.
Category: Developer
Features:
DatabaseUpdate:
Name: Database Update
Description: Commands for updating the database schema according to the definition of the "Record" classes in code.

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The Modules module enables the administrator of the site to manage the installed modules as well as activate and de-activate features.
Features:
Orchard.Modules:
Name: Modules
Description: Standard module and feature management.
FeatureDescription: Standard module and feature management.
Category: Core

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The multi-tenancy module enables multiple Orchard sites to run in isolation inside of a single web application, improving site density on a single server or hosted account.
Features:
Orchard.MultiTenancy:
Name: Multi Tenancy
Description: Configure multiple site tenants.
FeatureDescription: Configure multiple site tenants.
Category: Hosting

View File

@@ -5,16 +5,14 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The packaging module enables packaging modules using the OPC format.
FeatureDescription: Commands for creating/installing local modules.
Category: Packaging
Dependencies: PackagingServices
Features:
PackagingServices:
Name: Packaging Services
Description: Core services for packaging using the OPC format.
Category: Packaging
Orchard.Packaging:
Name: Packaging
Description: Commands for creating/installing local modules.
Category: Packaging
Dependencies: PackagingServices
Gallery:
Name: Gallery
Description: Module gallery management.

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: Introduces a preconfigured page content type.
Features:
Orchard.Pages:
Name: Pages
Description: A basic page content type.
FeatureDescription: A basic page content type.
Dependencies: Contents
Category: Content

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The PublishLater module introduces draft creation and scheduled publishing functionality.
Features:
Orchard.PublishLater:
Name: Publish Later
Description: Draft creation and scheduled publishing.
FeatureDescription: Draft creation and scheduled publishing.
Category: Content
Dependencies: Common, Scheduling, Orchard.jQuery

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: Provides Orchard Recipes.
Features:
Orchard.Recipes:
Name: Recipes
Description: Implementation of Orchard recipes.
FeatureDescription: Implementation of Orchard recipes.
Category: Core

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The roles module is adding the ability to assign roles to users. It's also providing a set of default roles for which other modules can define default permissions.
Features:
Orchard.Roles:
Name: Roles
Description: Standard user roles.
FeatureDescription: Standard user roles.
Category: Core
Dependencies: Orchard.Users

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The DLR scripting module enables the possibility to execute scripts using the DLR.
Features:
Orchard.Scripting.Dlr:
Name: DLR Scripting
Description: DLR scripting support.
FeatureDescription: DLR scripting support.
Dependencies: Orchard.Scripting
Category: Scripting

View File

@@ -5,11 +5,9 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The scripting module enables the possibility to execute scripts using a simple custom scripting language.
Features:
Orchard.Scripting:
Name: Scripting
Description: Scripting support.
FeatureDescription: Scripting support.
Category: Scripting
Features:
Orchard.Scripting.Lightweight:
Name: Lightweight scripting
Description: Custom lightweight and simple scripting language.

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The search module enables the management of the search index and provides the front-end searching user interface.
Features:
Orchard.Search:
Name: Search
Description: Standard interface to Orchard's built-in search.
FeatureDescription: Standard interface to Orchard's built-in search.
Category: Search
Dependencies: Orchard.Indexing

View File

@@ -4,8 +4,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The setup module is creating the application's setup experience.
Features:
Orchard.Setup:
Name: Setup
Description: Standard site setup. This feature is disabled automatically once setup is over.
FeatureDescription: Standard site setup. This feature is disabled automatically once setup is over.
Category: Core

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The tags module is providing basic tagging for arbitrary content types.
Features:
Orchard.Tags:
Name: Tags
Description: Tag a content item.
FeatureDescription: Tag a content item.
Dependencies: Settings
Category: Navigation

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The themes module makes it possible for Orchard applications to customize the look and feel of an Orchard web site.
Features:
Orchard.Themes:
Name: Themes
Description: Basic theming capability.
FeatureDescription: Basic theming capability.
Category: Core

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The users module enables user management.
Features:
Orchard.Users:
Name: Users
Description: Standard users.
FeatureDescription: Standard users.
Category: Core
Dependencies: Settings

View File

@@ -5,9 +5,6 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: An implementation of widgets for Orchard.
Features:
Orchard.Widgets:
Name: Widgets
Description: An implementation of widgets.
FeatureDescription: An implementation of widgets.
Category: Widget
Dependencies: Orchard.Scripting

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The jQuery module contains the jQuery and related script libraries.
Features:
Orchard.jQuery:
Name: jQuery
Description: A common location for jQuery and related script libraries.
FeatureDescription: A common location for jQuery and related script libraries.
Category: Core

View File

@@ -5,8 +5,5 @@ Website: http://orchardproject.net
Version: 1.0.20
OrchardVersion: 1.0.20
Description: The TinyMCE module enables rich text contents to be created using a "What You See Is What You Get" user interface.
Features:
TinyMce:
Name: TinyMce
Description: TinyMCE HTML WYSIWYG editor.
FeatureDescription: TinyMCE HTML WYSIWYG editor.
Category: Input Editor

View File

@@ -101,7 +101,7 @@ namespace Orchard.Environment.Extensions.Folders {
Zones = GetValue(manifest, "Zones"),
BaseTheme = GetValue(manifest, "BaseTheme"),
};
extensionDescriptor.Features = GetFeaturesForExtension(GetValue(manifest, "Features"), extensionDescriptor);
extensionDescriptor.Features = GetFeaturesForExtension(manifest, extensionDescriptor);
return extensionDescriptor;
}
@@ -174,6 +174,15 @@ namespace Orchard.Environment.Extensions.Folders {
case "BaseTheme":
manifest.Add("BaseTheme", field[1]);
break;
case "Dependencies":
manifest.Add("Dependencies", field[1]);
break;
case "Category":
manifest.Add("Category", field[1]);
break;
case "FeatureDescription":
manifest.Add("FeatureDescription", field[1]);
break;
case "Features":
manifest.Add("Features", reader.ReadToEnd());
break;
@@ -184,8 +193,23 @@ namespace Orchard.Environment.Extensions.Folders {
return manifest;
}
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(string featuresText, ExtensionDescriptor extensionDescriptor) {
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(IDictionary<string, string> manifest, ExtensionDescriptor extensionDescriptor) {
var featureDescriptors = new List<FeatureDescriptor>();
// Default feature
FeatureDescriptor defaultFeature = new FeatureDescriptor {
Id = extensionDescriptor.Id,
Name = extensionDescriptor.Name,
Description = GetValue(manifest, "FeatureDescription") ?? GetValue(manifest, "Description") ?? string.Empty,
Dependencies = ParseFeatureDependenciesEntry(GetValue(manifest, "Dependencies")),
Extension = extensionDescriptor,
Category = GetValue(manifest, "Category")
};
featureDescriptors.Add(defaultFeature);
// Remaining features
string featuresText = GetValue(manifest, "Features");
if (featuresText != null) {
FeatureDescriptor featureDescriptor = null;
using (StringReader reader = new StringReader(featuresText)) {
@@ -193,16 +217,24 @@ namespace Orchard.Environment.Extensions.Folders {
while ((line = reader.ReadLine()) != null) {
if (IsFeatureDeclaration(line)) {
if (featureDescriptor != null) {
if (!featureDescriptor.Equals(defaultFeature)) {
featureDescriptors.Add(featureDescriptor);
}
featureDescriptor = null;
}
string[] featureDeclaration = line.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
string featureDescriptorId = featureDeclaration[0].Trim();
if (featureDescriptorId == extensionDescriptor.Id) {
featureDescriptor = defaultFeature;
featureDescriptor.Name = extensionDescriptor.Name;
}
else {
featureDescriptor = new FeatureDescriptor {
Id = featureDescriptorId,
Extension = extensionDescriptor
};
string[] featureDeclaration = line.Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
featureDescriptor.Id = featureDeclaration[0].Trim();
if (featureDescriptor.Id == extensionDescriptor.Id) {
featureDescriptor.Name = extensionDescriptor.Name;
}
}
else if (IsFeatureFieldDeclaration(line)) {
@@ -239,20 +271,12 @@ namespace Orchard.Environment.Extensions.Folders {
throw new ArgumentException(message);
}
}
if (featureDescriptor != null)
if (featureDescriptor != null && !featureDescriptor.Equals(defaultFeature))
featureDescriptors.Add(featureDescriptor);
}
}
if (!featureDescriptors.Any(fd => fd.Id == extensionDescriptor.Id)) {
featureDescriptors.Add(new FeatureDescriptor {
Id = extensionDescriptor.Id,
Name = extensionDescriptor.Name,
Dependencies = new string[0],
Extension = extensionDescriptor
});
}
return featureDescriptors;
}
@@ -277,12 +301,15 @@ namespace Orchard.Environment.Extensions.Folders {
return false;
}
private static string[] ParseFeatureDependenciesEntry(string dependenciesEntry) {
private static IEnumerable<string> ParseFeatureDependenciesEntry(string dependenciesEntry) {
if (string.IsNullOrEmpty(dependenciesEntry))
return Enumerable.Empty<string>();
var dependencies = new List<string>();
foreach (var s in dependenciesEntry.Split(',')) {
dependencies.Add(s.Trim());
}
return dependencies.ToArray();
return dependencies;
}
private static string GetValue(IDictionary<string, string> fields, string key) {