PERF: Replacing YAML parser with a simpler implementation.

All external YAML references have been removed from Orchard.

--HG--
branch : perf
This commit is contained in:
Suha Can
2010-11-19 18:41:38 -08:00
parent 8e2497ffbf
commit e5aef055cf
12 changed files with 283 additions and 483 deletions

View File

@@ -1,47 +0,0 @@
--- 2009-10-04 Osamu TAKEUCHI <osamu@big.jp>
Alpha release of YamlSerializer as 0.9.0.2
* All "_"s in integer and floating point values are neglected
to accommodate the !!int and !!float encoding.
* YamlConfig.DontUseVerbatimTag is added but the default value is set false.
Note that !<!System.Int32[,]> is much human friendly than !System.Int32%5B%2C%5D.
* Equality of YamlNode with an unknown tag is evaluated by identity,
while that of !!map and !!seq node is still evaluated by YAML's standard.
Note that equality of !!map and !!seq are different from that of object[]
and Dictionary<object, object>.
* YamlConfig.OmitTagForRootNode was added. Fixed issue #2850.
* Serialize Dictionary<object,object> to !!map. Fixed #2891.
* Modified [126-130] ns-plain-???, [147] c-ns-flow-map-separate-value(n,c)
to accommodate revision 2009-10-01
* Omit !< > if Tag contains only ns-tag-char, Fixed issue #2813
--- 2009-09-23 Osamu TAKEUCHI <osamu@big.jp>
Alpha release of YamlSerializer as 0.9.0.1
* Removed TODO's for reporting bugs in YAML spec that are done.
* Fixed assembly copyright.
* !!merge is supported. Fixed issue#2605.
* Read-only class-type member with no child members are omitted when
serializing. Fixed issue#2599.
* Culture for TypeConverter is set to be CultureInfo.InvariantCulture.
Fixed issue #2629.
* To fix Issue#2631
* Field names and property names are always presented as simple texts.
* When deserializing, we can not avoid the parser parses some spacial
names to !!bool and !!null. Such non-text nodes are converted to
texts at construction stage.
* To fix issue#2663
* Hash code stored in a mapping node is now updated when the a key node's
content is changed.
* Hash code and equality became independent on the order of keys in a
mapping node.
* A mapping node checks for duplicated keys every time the node content
is changed.
* Test results are changed because some of them are dependent on the hash
key order.
* The current equality evaluation is too strict, probably needs some adjustment.
* NativeObject property was added to YamlScalar.
* YamlScalar's equality is evaluated by comparing NativeObject.
--- 2009-09-11 Osamu TAKEUCHI <osamu@big.jp>
First release of YamlSerializer as 0.9.0.0

View File

@@ -1,177 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

View File

@@ -1,39 +0,0 @@
YamlSerializer 0.9.0.2 (2009-10-04) Osamu TAKEUCHI <osamu@big.jp>
Description:
A library that serialize / deserialize C# native objects into YAML1.2 text.
Development environment:
Visual C# 2008 Express Edition
Sandcastle (2008-05-29)
SandcastleBuilder 1.8.0.2
HTML Help workshop 4.74.8702
NUnit 2.5.0.9122
TestDriven.NET 2.0
Support web page:
http://yamlserializer.codeplex.com/
License:
YamlSerializer is distributed under the MIT license as following:
---
The MIT License (MIT)
Copyright (c) 2009 Osamu TAKEUCHI <osamu@big.jp>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Binary file not shown.

View File

@@ -93,8 +93,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
}
@@ -108,8 +108,7 @@ Features:
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
foreach (var e in Manifests) {
string name = e.Key;
var parseResult = ExtensionFolders.ParseManifest(Manifests[name]);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, "Module", parseResult);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, "Module", Manifests[name]);
}
}
}

View File

@@ -20,7 +20,6 @@ using Orchard.Environment.Extensions.Models;
using Orchard.Tests.ContentManagement;
using Orchard.Data.Providers;
using Orchard.Tests.Stubs;
using Orchard.Tests.Utility;
namespace Orchard.Tests.DataMigration {
[TestFixture]
@@ -91,8 +90,7 @@ namespace Orchard.Tests.DataMigration {
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
foreach (var e in Manifests) {
string name = e.Key;
var parseResult = ExtensionFolders.ParseManifest(Manifests[name]);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, "Module", parseResult);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, "Module", Manifests[name]);
}
}
}
@@ -235,8 +233,8 @@ Name: Module2
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
@@ -252,8 +250,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
@@ -269,8 +267,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
@@ -288,8 +286,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
@@ -306,8 +304,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_repository.Create(new DataMigrationRecord {
Version = 42,
@@ -329,9 +327,9 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Dependencies: Feature2
Feature1:
Description: Feature
Dependencies: Feature2
");
_folders.Manifests.Add("Module2", @"
@@ -339,8 +337,8 @@ Name: Module2
Version: 0.1
OrchardVersion: 1
Features:
Feature2:
Description: Feature
Feature2:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(2));
@@ -358,8 +356,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
@@ -376,14 +374,14 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature2:
Description: Feature
Feature3:
Description: Feature
Feature4:
Description: Feature
Feature1:
Description: Feature
Feature2:
Description: Feature
Feature3:
Description: Feature
Feature4:
Description: Feature
");
// even if there is a data migration class, as it is empty there should me no migration to do
@@ -425,8 +423,8 @@ Name: Module1
Version: 0.1
OrchardVersion: 1
Features:
Feature1:
Description: Feature
Feature1:
Description: Feature
");
_dataMigrationManager.Update("Feature1");

View File

@@ -45,8 +45,7 @@ namespace Orchard.Tests.Environment.Extensions {
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
foreach (var e in Manifests) {
string name = e.Key;
var parseResult = ExtensionFolders.ParseManifest(Manifests[name]);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, _extensionType, parseResult);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, _extensionType, Manifests[name]);
}
}
}
@@ -157,8 +156,8 @@ Name: SuperWiki
Version: 1.0.3
OrchardVersion: 1
Features:
SuperWiki:
Description: My super wiki module for Orchard.
SuperWiki:
Description: My super wiki module for Orchard.
");
var descriptor = _manager.AvailableExtensions().Single();
@@ -181,22 +180,22 @@ Website: http://anotherwiki.codeplex.com
Version: 1.2.3
OrchardVersion: 1
Features:
AnotherWiki:
Description: My super wiki module for Orchard.
Dependencies: Versioning, Search
Category: Content types
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
AnotherWiki:
Description: My super wiki module for Orchard.
Dependencies: Versioning, Search
Category: Content types
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();
@@ -262,10 +261,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -288,10 +287,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -323,10 +322,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -353,10 +352,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -381,10 +380,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());

View File

@@ -49,8 +49,7 @@ namespace Orchard.Tests.Environment.Extensions {
public IEnumerable<ExtensionDescriptor> AvailableExtensions() {
foreach (var e in Manifests) {
string name = e.Key;
var parseResult = ExtensionFolders.ParseManifest(Manifests[name]);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, _extensionType, parseResult);
yield return ExtensionFolders.GetDescriptorForExtension("~/", name, _extensionType, Manifests[name]);
}
}
}
@@ -161,8 +160,8 @@ Name: SuperWiki
Version: 1.0.3
OrchardVersion: 1
Features:
SuperWiki:
Description: My super wiki module for Orchard.
SuperWiki:
Description: My super wiki module for Orchard.
");
var descriptor = _manager.AvailableExtensions().Single();
@@ -185,22 +184,22 @@ Website: http://anotherwiki.codeplex.com
Version: 1.2.3
OrchardVersion: 1
Features:
AnotherWiki:
Description: My super wiki module for Orchard.
Dependencies: Versioning, Search
Category: Content types
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
AnotherWiki:
Description: My super wiki module for Orchard.
Dependencies: Versioning, Search
Category: Content types
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();
@@ -266,10 +265,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -292,10 +291,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -327,10 +326,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -357,10 +356,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -385,10 +384,10 @@ Name: TestModule
Version: 1.0.3
OrchardVersion: 1
Features:
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
TestModule:
Description: My test module for Orchard.
TestFeature:
Description: Contains the Phi type.
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -433,8 +432,8 @@ Name: Alpha
Version: 1.0.3
OrchardVersion: 1
Features:
Alpha:
Dependencies: Gamma
Alpha:
Dependencies: Gamma
");
extensionFolder.Manifests.Add("Beta", @"
@@ -447,8 +446,8 @@ Name: Gamma
Version: 1.0.3
OrchardVersion: 1
Features:
Gamma:
Dependencies: Beta
Gamma:
Dependencies: Beta
");
IExtensionManager extensionManager = new ExtensionManager(new[] { extensionFolder }, new[] { extensionLoader }, new StubCacheManager());
@@ -467,8 +466,8 @@ Name: Alpha
Version: 1.0.3
OrchardVersion: 1
Features:
Alpha:
Dependencies: Gamma
Alpha:
Dependencies: Gamma
");
moduleExtensionFolder.Manifests.Add("Beta", @"
@@ -481,8 +480,8 @@ Name: Gamma
Version: 1.0.3
OrchardVersion: 1
Features:
Gamma:
Dependencies: Beta
Gamma:
Dependencies: Beta
");
moduleExtensionFolder.Manifests.Add("Classic", @"
@@ -507,8 +506,8 @@ Name: Alpha
Version: 1.0.3
OrchardVersion: 1
Features:
Alpha:
Dependencies: Gamma
Alpha:
Dependencies: Gamma
");
moduleExtensionFolder.Manifests.Add("Beta", @"
@@ -521,8 +520,8 @@ Name: Gamma
Version: 1.0.3
OrchardVersion: 1
Features:
Gamma:
Dependencies: Beta
Gamma:
Dependencies: Beta
");
moduleExtensionFolder.Manifests.Add("Classic", @"
@@ -530,8 +529,8 @@ Name: Classic
Version: 1.0.3
OrchardVersion: 1
Features:
Classic:
Dependencies: Alpha
Classic:
Dependencies: Alpha
");
IExtensionManager extensionManager = new ExtensionManager(new[] { moduleExtensionFolder, themeExtensionFolder }, new[] { extensionLoader }, new StubCacheManager());

View File

@@ -7,15 +7,8 @@ using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.WebSite;
using Orchard.Localization;
using Orchard.Logging;
using Yaml.Grammar;
namespace Orchard.Environment.Extensions.Folders {
public class ParseResult {
public string Location { get; set; }
public string Name { get; set; }
public YamlDocument YamlDocument { get; set; }
}
public class ExtensionFolders : IExtensionFolders {
private readonly IEnumerable<string> _paths;
private readonly string _manifestName;
@@ -73,11 +66,31 @@ namespace Orchard.Environment.Extensions.Folders {
return list;
}
public static ExtensionDescriptor GetDescriptorForExtension(string locationPath, string extensionName, string extensionType, string manifestText) {
Dictionary<string, string> manifest = ParseManifest(manifestText);
var extensionDescriptor = new ExtensionDescriptor {
Location = locationPath,
Name = extensionName,
ExtensionType = extensionType,
DisplayName = GetValue(manifest, "Name") ?? extensionName,
Description = GetValue(manifest, "Description"),
Version = GetValue(manifest, "Version"),
OrchardVersion = GetValue(manifest, "OrchardVersion"),
Author = GetValue(manifest, "Author"),
WebSite = GetValue(manifest, "Website"),
Tags = GetValue(manifest, "Tags"),
AntiForgery = GetValue(manifest, "AntiForgery"),
Zones = GetValue(manifest, "Zones"),
BaseTheme = GetValue(manifest, "BaseTheme"),
};
extensionDescriptor.Features = GetFeaturesForExtension(GetValue(manifest, "Features"), extensionDescriptor);
return extensionDescriptor;
}
private ExtensionDescriptor GetExtensionDescriptor(string locationPath, string extensionName, string manifestPath) {
return _cacheManager.Get(manifestPath, context => {
context.Monitor(_webSiteFolder.WhenPathChanges(manifestPath));
var manifestText = _webSiteFolder.ReadFile(manifestPath);
if (manifestText == null) {
if (_manifestIsOptional) {
@@ -88,84 +101,128 @@ namespace Orchard.Environment.Extensions.Folders {
}
}
return GetDescriptorForExtension(locationPath, extensionName, ParseManifest(manifestText));
return GetDescriptorForExtension(locationPath, extensionName, manifestText);
});
}
private ExtensionDescriptor GetDescriptorForExtension(string locationPath, string extensionName, ParseResult parseResult) {
return GetDescriptorForExtension(locationPath, extensionName, _extensionType, parseResult);
private ExtensionDescriptor GetDescriptorForExtension(string locationPath, string extensionName, string manifestText) {
return GetDescriptorForExtension(locationPath, extensionName, _extensionType, manifestText);
}
public static ParseResult ParseManifest(string manifestText) {
bool success;
var yamlStream = new YamlParser().ParseYamlStream(new TextInput(manifestText), out success);
if (yamlStream == null || !success) {
return null;
}
return new ParseResult {
Name = manifestText,
YamlDocument = yamlStream.Documents.Single()
};
}
private static Dictionary<string, string> ParseManifest(string manifestText) {
var manifest = new Dictionary<string, string>();
public static ExtensionDescriptor GetDescriptorForExtension(string locationPath, string extensionName, string extensionType, ParseResult parseResult) {
var mapping = (Mapping)parseResult.YamlDocument.Root;
var fields = mapping.Entities
.Where(x => x.Key is Scalar)
.ToDictionary(x => ((Scalar)x.Key).Text, x => x.Value);
var extensionDescriptor = new ExtensionDescriptor {
Location = locationPath,
Name = extensionName,
ExtensionType = extensionType,
DisplayName = GetValue(fields, "Name") ?? extensionName,
Description = GetValue(fields, "Description"),
Version = GetValue(fields, "Version"),
OrchardVersion = GetValue(fields, "OrchardVersion"),
Author = GetValue(fields, "Author"),
WebSite = GetValue(fields, "Website"),
Tags = GetValue(fields, "Tags"),
AntiForgery = GetValue(fields, "AntiForgery"),
Zones = GetValue(fields, "Zones"),
BaseTheme = GetValue(fields, "BaseTheme"),
};
extensionDescriptor.Features = GetFeaturesForExtension(GetMapping(fields, "Features"), extensionDescriptor);
return extensionDescriptor;
}
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(Mapping features, ExtensionDescriptor extensionDescriptor) {
var featureDescriptors = new List<FeatureDescriptor>();
if (features != null) {
foreach (var entity in features.Entities) {
var featureDescriptor = new FeatureDescriptor {
Extension = extensionDescriptor,
Name = entity.Key.ToString(),
};
if (featureDescriptor.Name == extensionDescriptor.Name) {
featureDescriptor.DisplayName = extensionDescriptor.DisplayName;
using (StringReader reader = new StringReader(manifestText)) {
string line;
while ((line = reader.ReadLine()) != null) {
string[] field = line.Split(new[] {":"}, 2, StringSplitOptions.None);
int fieldLength = field.Length;
if (fieldLength != 2)
continue;
for (int i = 0; i < fieldLength; i++) {
field[i] = field[i].Trim();
}
var featureMapping = (Mapping)entity.Value;
foreach (var featureEntity in featureMapping.Entities) {
if (featureEntity.Key.ToString() == "Description") {
featureDescriptor.Description = featureEntity.Value.ToString();
}
else if (featureEntity.Key.ToString() == "Category") {
featureDescriptor.Category = featureEntity.Value.ToString();
}
else if (featureEntity.Key.ToString() == "Name") {
featureDescriptor.DisplayName = featureEntity.Value.ToString();
}
else if (featureEntity.Key.ToString() == "Dependencies") {
featureDescriptor.Dependencies = ParseFeatureDependenciesEntry(featureEntity.Value.ToString());
}
switch (field[0]) {
case "Name":
manifest.Add("Name", field[1]);
break;
case "Description":
manifest.Add("Description", field[1]);
break;
case "Version":
manifest.Add("Version", field[1]);
break;
case "OrchardVersion":
manifest.Add("OrchardVersion", field[1]);
break;
case "Author":
manifest.Add("Author", field[1]);
break;
case "Website":
manifest.Add("Website", field[1]);
break;
case "Tags":
manifest.Add("Tags", field[1]);
break;
case "AntiForgery":
manifest.Add("AntiForgery", field[1]);
break;
case "Zones":
manifest.Add("Zones", field[1]);
break;
case "BaseTheme":
manifest.Add("BaseTheme", field[1]);
break;
case "Features":
manifest.Add("Features", reader.ReadToEnd());
break;
}
featureDescriptors.Add(featureDescriptor);
}
}
return manifest;
}
private static IEnumerable<FeatureDescriptor> GetFeaturesForExtension(string featuresText, ExtensionDescriptor extensionDescriptor) {
var featureDescriptors = new List<FeatureDescriptor>();
if (featuresText != null) {
FeatureDescriptor featureDescriptor = null;
using (StringReader reader = new StringReader(featuresText)) {
string line;
while ((line = reader.ReadLine()) != null) {
if (IsFeatureDeclaration(line)) {
if (featureDescriptor != null) {
featureDescriptors.Add(featureDescriptor);
featureDescriptor = null;
}
featureDescriptor = new FeatureDescriptor {
Extension = extensionDescriptor
};
string[] featureDeclaration = line.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries);
featureDescriptor.Name = featureDeclaration[0].Trim();
if (featureDescriptor.Name == extensionDescriptor.Name) {
featureDescriptor.DisplayName = extensionDescriptor.DisplayName;
}
}
else if (IsFeatureFieldDeclaration(line)) {
if (featureDescriptor != null) {
string[] featureField = line.Split(new[] {":"}, 2, StringSplitOptions.None);
int featureFieldLength = featureField.Length;
if (featureFieldLength != 2)
continue;
for (int i = 0; i < featureFieldLength; i++) {
featureField[i] = featureField[i].Trim();
}
switch (featureField[0]) {
case "Name":
featureDescriptor.DisplayName = featureField[1];
break;
case "Description":
featureDescriptor.Description = featureField[1];
break;
case "Category":
featureDescriptor.Category = featureField[1];
break;
case "Dependencies":
featureDescriptor.Dependencies = ParseFeatureDependenciesEntry(featureField[1]);
break;
}
}
else {
string message = string.Format("The line {0} in manifest for extension {1} was ignored", line, extensionDescriptor.Name);
throw new ArgumentException(message);
}
}
else {
string message = string.Format("The line {0} in manifest for extension {1} was ignored", line, extensionDescriptor.Name);
throw new ArgumentException(message);
}
}
if (featureDescriptor != null)
featureDescriptors.Add(featureDescriptor);
}
}
if (!featureDescriptors.Any(fd => fd.Name == extensionDescriptor.Name)) {
featureDescriptors.Add(new FeatureDescriptor {
Name = extensionDescriptor.Name,
@@ -174,9 +231,31 @@ namespace Orchard.Environment.Extensions.Folders {
Extension = extensionDescriptor
});
}
return featureDescriptors;
}
private static bool IsFeatureFieldDeclaration(string line) {
if (line.StartsWith("\t\t") ||
line.StartsWith("\t ") ||
line.StartsWith(" ") ||
line.StartsWith(" \t"))
return true;
return false;
}
private static bool IsFeatureDeclaration(string line) {
int lineLength = line.Length;
if (line.StartsWith("\t") && lineLength >= 2) {
return !Char.IsWhiteSpace(line[1]);
}
if (line.StartsWith(" ") && lineLength >= 5)
return !Char.IsWhiteSpace(line[4]);
return false;
}
private static string[] ParseFeatureDependenciesEntry(string dependenciesEntry) {
var dependencies = new List<string>();
foreach (var s in dependenciesEntry.Split(',')) {
@@ -185,14 +264,9 @@ namespace Orchard.Environment.Extensions.Folders {
return dependencies.ToArray();
}
private static Mapping GetMapping(IDictionary<string, DataItem> fields, string key) {
DataItem value;
return fields.TryGetValue(key, out value) ? (Mapping)value : null;
}
private static string GetValue(IDictionary<string, DataItem> fields, string key) {
DataItem value;
return fields.TryGetValue(key, out value) ? value.ToString() : null;
private static string GetValue(IDictionary<string, string> fields, string key) {
string value;
return fields.TryGetValue(key, out value) ? value : null;
}
}
}

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Orchard.Environment.Extensions.Models;
using Yaml.Grammar;
namespace Orchard.Environment.Extensions.Folders {
public interface IExtensionFolders {

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
namespace Orchard.Environment.Extensions.Models {
public class ExtensionDescriptor {

View File

@@ -149,10 +149,6 @@
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Yaml, Version=1.0.3370.39839, Culture=neutral, PublicKeyToken=187a3d240e44a135, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\yaml\Yaml.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ContentManagement\DefaultContentDisplay.cs" />