mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-02 11:44:41 +08:00
Refactoring Bags and moving to Orchard.Framework
--HG-- branch : 1.x extra : rebase_source : 0f934cffae32b4477ee39be01bcc63d36982b6b8
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using Orchard.Projections.Settings;
|
using Orchard.Data.Bags;
|
||||||
|
using Orchard.Data.Bags.Serialization;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Orchard.Projections.Settings.Serialization;
|
|
||||||
|
|
||||||
namespace Orchard.Projections.Tests.Settings {
|
namespace Orchard.Tests.Data.Bags {
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class SettingsTests {
|
public class BagsTests {
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldRemoveMember() {
|
public void ShouldRemoveMember() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
e.Foo = "Bar";
|
e.Foo = "Bar";
|
||||||
Assert.That(e, Is.Not.Empty);
|
Assert.That(e, Is.Not.Empty);
|
||||||
Assert.That(e.Foo, Is.EqualTo("Bar"));
|
Assert.That(e.Foo, Is.EqualTo("Bar"));
|
||||||
@@ -20,7 +20,7 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldSupportFactoryInvocation() {
|
public void ShouldSupportFactoryInvocation() {
|
||||||
var e = SObject.New();
|
var e = Bag.New();
|
||||||
|
|
||||||
e.Foo = "Bar";
|
e.Foo = "Bar";
|
||||||
Assert.That(e["Foo"], Is.EqualTo("Bar"));
|
Assert.That(e["Foo"], Is.EqualTo("Bar"));
|
||||||
@@ -29,7 +29,7 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldAddDynamicProperties() {
|
public void ShouldAddDynamicProperties() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
e.Foo = "Bar";
|
e.Foo = "Bar";
|
||||||
Assert.That(e["Foo"], Is.EqualTo("Bar"));
|
Assert.That(e["Foo"], Is.EqualTo("Bar"));
|
||||||
Assert.That(e.Foo, Is.EqualTo("Bar"));
|
Assert.That(e.Foo, Is.EqualTo("Bar"));
|
||||||
@@ -37,15 +37,15 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void UnknownPropertiesShouldBeNull() {
|
public void UnknownPropertiesShouldBeNull() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
Assert.That((object)e["Foo"], Is.EqualTo(null));
|
Assert.That((object)e["Foo"], Is.EqualTo(null));
|
||||||
Assert.That((object)e.Foo, Is.EqualTo(null));
|
Assert.That((object)e.Foo, Is.EqualTo(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldAddDynamicObjects() {
|
public void ShouldAddDynamicObjects() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
e.Address = new SObject();
|
e.Address = new Bag();
|
||||||
|
|
||||||
e.Address.Street = "One Microsoft Way";
|
e.Address.Street = "One Microsoft Way";
|
||||||
Assert.That(e["Address"]["Street"], Is.EqualTo("One Microsoft Way"));
|
Assert.That(e["Address"]["Street"], Is.EqualTo("One Microsoft Way"));
|
||||||
@@ -53,7 +53,7 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ShouldAddArraysOfAnonymousObject() {
|
public void ShouldAddArraysOfAnonymousObject() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
|
|
||||||
e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
|
e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
|
||||||
Assert.That(e.Foos[0].Foo1, Is.EqualTo("Bar1"));
|
Assert.That(e.Foos[0].Foo1, Is.EqualTo("Bar1"));
|
||||||
@@ -61,7 +61,7 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void ShouldAddAnonymousObject() {
|
public void ShouldAddAnonymousObject() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
|
|
||||||
e.Foos = new { Foo1 = "Bar1", Foo2 = "Bar2" };
|
e.Foos = new { Foo1 = "Bar1", Foo2 = "Bar2" };
|
||||||
Assert.That(e.Foos.Foo1, Is.EqualTo("Bar1"));
|
Assert.That(e.Foos.Foo1, Is.EqualTo("Bar1"));
|
||||||
@@ -70,7 +70,7 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldAddArrays() {
|
public void ShouldAddArrays() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
e.Owners = new[] { "Steve", "Bill" };
|
e.Owners = new[] { "Steve", "Bill" };
|
||||||
Assert.That(e.Owners[0], Is.EqualTo("Steve"));
|
Assert.That(e.Owners[0], Is.EqualTo("Steve"));
|
||||||
Assert.That(e.Owners[1], Is.EqualTo("Bill"));
|
Assert.That(e.Owners[1], Is.EqualTo("Bill"));
|
||||||
@@ -78,8 +78,8 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldBeEnumerable() {
|
public void ShouldBeEnumerable() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
e.Address = new SObject();
|
e.Address = new Bag();
|
||||||
|
|
||||||
e.Address.Street = "One Microsoft Way";
|
e.Address.Street = "One Microsoft Way";
|
||||||
e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
|
e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
|
||||||
@@ -93,11 +93,11 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void ShouldSerializeAndDeserialize() {
|
public void ShouldSerializeAndDeserialize() {
|
||||||
dynamic e = new SObject();
|
dynamic e = new Bag();
|
||||||
|
|
||||||
e.Foo = "Bar";
|
e.Foo = "Bar";
|
||||||
|
|
||||||
e.Address = new SObject();
|
e.Address = new Bag();
|
||||||
e.Address.Street = "One Microsoft Way";
|
e.Address.Street = "One Microsoft Way";
|
||||||
e.Owners = new[] { "Steve", "Bill" };
|
e.Owners = new[] { "Steve", "Bill" };
|
||||||
e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
|
e.Foos = new[] { new { Foo1 = "Bar1", Foo2 = "Bar2" } };
|
||||||
@@ -128,11 +128,11 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void MergeShouldOverwriteExistingProperties() {
|
public void MergeShouldOverwriteExistingProperties() {
|
||||||
var o1 = SObject.New();
|
var o1 = Bag.New();
|
||||||
o1.Foo = "Foo1";
|
o1.Foo = "Foo1";
|
||||||
o1.Bar = "Bar1";
|
o1.Bar = "Bar1";
|
||||||
|
|
||||||
var o2 = SObject.New();
|
var o2 = Bag.New();
|
||||||
o2.Foo = "Foo2";
|
o2.Foo = "Foo2";
|
||||||
o2.Baz = "Baz2";
|
o2.Baz = "Baz2";
|
||||||
|
|
||||||
@@ -145,10 +145,10 @@ namespace Orchard.Projections.Tests.Settings {
|
|||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void MergeShouldConcatenateArrays() {
|
public void MergeShouldConcatenateArrays() {
|
||||||
var o1 = SObject.New();
|
var o1 = Bag.New();
|
||||||
o1.Foo = new[] { "a", "b" };
|
o1.Foo = new[] { "a", "b" };
|
||||||
|
|
||||||
var o2 = SObject.New();
|
var o2 = Bag.New();
|
||||||
o2.Foo = new[] { "c", "d" };
|
o2.Foo = new[] { "c", "d" };
|
||||||
|
|
||||||
var o3 = o1 & o2;
|
var o3 = o1 & o2;
|
||||||
@@ -217,6 +217,7 @@
|
|||||||
<Compile Include="Data\ProviderUtilities.cs" />
|
<Compile Include="Data\ProviderUtilities.cs" />
|
||||||
<Compile Include="Data\RepositoryTests.cs" />
|
<Compile Include="Data\RepositoryTests.cs" />
|
||||||
<Compile Include="Data\ProvidersTests.cs" />
|
<Compile Include="Data\ProvidersTests.cs" />
|
||||||
|
<Compile Include="Data\Bags\SettingsTests.cs" />
|
||||||
<Compile Include="Data\StubLocator.cs" />
|
<Compile Include="Data\StubLocator.cs" />
|
||||||
<Compile Include="DisplayManagement\ArgsUtility.cs" />
|
<Compile Include="DisplayManagement\ArgsUtility.cs" />
|
||||||
<Compile Include="DisplayManagement\DefaultDisplayManagerTests.cs" />
|
<Compile Include="DisplayManagement\DefaultDisplayManagerTests.cs" />
|
||||||
|
|||||||
@@ -21,6 +21,10 @@
|
|||||||
</UpgradeBackupLocation>
|
</UpgradeBackupLocation>
|
||||||
<TargetFrameworkProfile />
|
<TargetFrameworkProfile />
|
||||||
<UseIISExpress>false</UseIISExpress>
|
<UseIISExpress>false</UseIISExpress>
|
||||||
|
<IISExpressSSLPort />
|
||||||
|
<IISExpressAnonymousAuthentication />
|
||||||
|
<IISExpressWindowsAuthentication />
|
||||||
|
<IISExpressUseClassicPipelineMode />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
@@ -217,16 +221,8 @@
|
|||||||
<Compile Include="Services\PropertyShapes.cs" />
|
<Compile Include="Services\PropertyShapes.cs" />
|
||||||
<Compile Include="Services\ProjectionManager.cs" />
|
<Compile Include="Services\ProjectionManager.cs" />
|
||||||
<Compile Include="Services\QueryService.cs" />
|
<Compile Include="Services\QueryService.cs" />
|
||||||
<Compile Include="Settings\Serialization\XmlSettingsSerializer.cs" />
|
|
||||||
<Compile Include="Settings\Serialization\ISettingsSerializer.cs" />
|
|
||||||
<Compile Include="Services\FieldIndexService.cs" />
|
<Compile Include="Services\FieldIndexService.cs" />
|
||||||
<Compile Include="Services\IFieldIndexService.cs" />
|
<Compile Include="Services\IFieldIndexService.cs" />
|
||||||
<Compile Include="Settings\SArray.cs" />
|
|
||||||
<Compile Include="Settings\SConvert.cs" />
|
|
||||||
<Compile Include="Settings\SItem.cs" />
|
|
||||||
<Compile Include="Settings\StateValueProvider.cs" />
|
|
||||||
<Compile Include="Settings\SValue.cs" />
|
|
||||||
<Compile Include="Settings\SObject.cs" />
|
|
||||||
<Compile Include="StandardQueries\QueryFeedQuery.cs" />
|
<Compile Include="StandardQueries\QueryFeedQuery.cs" />
|
||||||
<Compile Include="ViewModels\BindingIndexViewModel.cs" />
|
<Compile Include="ViewModels\BindingIndexViewModel.cs" />
|
||||||
<Compile Include="ViewModels\BindingSelectViewModel.cs" />
|
<Compile Include="ViewModels\BindingSelectViewModel.cs" />
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using Orchard.Projections.Settings;
|
using Orchard.Data.Bags;
|
||||||
|
|
||||||
namespace Orchard.Projections.Services {
|
namespace Orchard.Projections.Services {
|
||||||
public static class FormParametersHelper {
|
public static class FormParametersHelper {
|
||||||
@@ -43,7 +43,7 @@ namespace Orchard.Projections.Services {
|
|||||||
|
|
||||||
|
|
||||||
public static dynamic ToDynamic(string parameters) {
|
public static dynamic ToDynamic(string parameters) {
|
||||||
var result = SObject.New();
|
var result = Bag.New();
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(parameters)) {
|
if (String.IsNullOrEmpty(parameters)) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings.Serialization {
|
|
||||||
public interface ISettingsSerializer : IDependency {
|
|
||||||
void Serialize(TextWriter tw, SObject o);
|
|
||||||
SObject Deserialize(TextReader tr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -66,7 +66,6 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\FieldIndexServiceTests.cs" />
|
<Compile Include="Services\FieldIndexServiceTests.cs" />
|
||||||
<Compile Include="Services\FieldIndexStorageTests.cs" />
|
<Compile Include="Services\FieldIndexStorageTests.cs" />
|
||||||
<Compile Include="Settings\SettingsTests.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\..\Orchard.Tests\Orchard.Framework.Tests.csproj">
|
<ProjectReference Include="..\..\..\..\Orchard.Tests\Orchard.Framework.Tests.csproj">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Dynamic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings {
|
namespace Orchard.Data.Bags {
|
||||||
public class SArray : DynamicObject, ISItem {
|
public class SArray : DynamicObject, ISItem {
|
||||||
public ISItem[] Values { get; private set; }
|
public ISItem[] Values { get; private set; }
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ namespace Orchard.Projections.Settings {
|
|||||||
return new SArray(o1.Values.Union(new[] { o1 }).ToArray());
|
return new SArray(o1.Values.Union(new[] { o1 }).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SObject operator &(SArray o1, SObject o2) {
|
public static Bag operator &(SArray o1, Bag o2) {
|
||||||
return o2;
|
return o2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4,14 +4,14 @@ using System.Reflection;
|
|||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings {
|
namespace Orchard.Data.Bags {
|
||||||
public class SConvert {
|
public class SConvert {
|
||||||
public static ISItem ToSettings(object o) {
|
public static ISItem ToSettings(object o) {
|
||||||
if (o is SValue) {
|
if (o is SValue) {
|
||||||
return (ISItem)o;
|
return (ISItem)o;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o is SObject) {
|
if (o is Bag) {
|
||||||
return (ISItem)o;
|
return (ISItem)o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ namespace Orchard.Projections.Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (IsAnonymousType(o.GetType())) {
|
if (IsAnonymousType(o.GetType())) {
|
||||||
dynamic grappe = new SObject();
|
dynamic grappe = new Bag();
|
||||||
|
|
||||||
foreach (var p in o.GetType().GetProperties()) {
|
foreach (var p in o.GetType().GetProperties()) {
|
||||||
grappe[p.Name] = p.GetValue(o, null);
|
grappe[p.Name] = p.GetValue(o, null);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings {
|
namespace Orchard.Data.Bags {
|
||||||
public interface ISItem : ICloneable {
|
public interface ISItem : ICloneable {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Dynamic;
|
using System.Dynamic;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings {
|
namespace Orchard.Data.Bags {
|
||||||
public class SObject : DynamicObject, IEnumerable<KeyValuePair<string, object>>, ISItem {
|
public class Bag : DynamicObject, IEnumerable<KeyValuePair<string, object>>, ISItem {
|
||||||
internal readonly Dictionary<string, ISItem> _properties = new Dictionary<string, ISItem>();
|
internal readonly Dictionary<string, ISItem> _properties = new Dictionary<string, ISItem>();
|
||||||
|
|
||||||
public static dynamic New() {
|
public static dynamic New() {
|
||||||
return new SObject();
|
return new Bag();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool TrySetMember(SetMemberBinder binder, object value) {
|
public override bool TrySetMember(SetMemberBinder binder, object value) {
|
||||||
@@ -52,12 +52,12 @@ namespace Orchard.Projections.Settings {
|
|||||||
return GetMember(indexes[0].ToString(), out result);
|
return GetMember(indexes[0].ToString(), out result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SObject operator &(SObject o1, SObject o2) {
|
public static Bag operator &(Bag o1, Bag o2) {
|
||||||
if (o1 == null) {
|
if (o1 == null) {
|
||||||
return o2;
|
return o2;
|
||||||
}
|
}
|
||||||
|
|
||||||
var clone = (SObject)o1.Clone();
|
var clone = (Bag)o1.Clone();
|
||||||
dynamic dclone = clone;
|
dynamic dclone = clone;
|
||||||
|
|
||||||
foreach (var pair in o2._properties) {
|
foreach (var pair in o2._properties) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings {
|
namespace Orchard.Data.Bags {
|
||||||
public class SValue : ISItem {
|
public class SValue : ISItem {
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ namespace Orchard.Projections.Settings {
|
|||||||
return new SArray(new[] { o1 }.Union(o2.Values).ToArray());
|
return new SArray(new[] { o1 }.Union(o2.Values).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SObject operator &(SValue o1, SObject o2) {
|
public static Bag operator &(SValue o1, Bag o2) {
|
||||||
return o2;
|
return o2;
|
||||||
}
|
}
|
||||||
|
|
||||||
8
src/Orchard/Data/Bags/Serialization/IBagSerializer.cs
Normal file
8
src/Orchard/Data/Bags/Serialization/IBagSerializer.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Orchard.Data.Bags.Serialization {
|
||||||
|
public interface IBagSerializer : IDependency {
|
||||||
|
void Serialize(TextWriter tw, Bag o);
|
||||||
|
Bag Deserialize(TextReader tr);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,11 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings.Serialization {
|
namespace Orchard.Data.Bags.Serialization {
|
||||||
public class XmlSettingsSerializer : ISettingsSerializer {
|
public class XmlSettingsSerializer : IBagSerializer {
|
||||||
private const string Root = "SObject";
|
private const string Root = "Bag";
|
||||||
|
|
||||||
public void Serialize(TextWriter tw, SObject o) {
|
public void Serialize(TextWriter tw, Bag o) {
|
||||||
using (var writer = new XmlTextWriter(tw)) {
|
using (var writer = new XmlTextWriter(tw)) {
|
||||||
writer.WriteStartDocument();
|
writer.WriteStartDocument();
|
||||||
writer.WriteStartElement(Root);
|
writer.WriteStartElement(Root);
|
||||||
@@ -17,9 +17,9 @@ namespace Orchard.Projections.Settings.Serialization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SObject Deserialize(TextReader tr) {
|
public Bag Deserialize(TextReader tr) {
|
||||||
var reader = new XmlTextReader(tr);
|
var reader = new XmlTextReader(tr);
|
||||||
var result = new SObject();
|
var result = new Bag();
|
||||||
|
|
||||||
// ignore root element
|
// ignore root element
|
||||||
while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == Root) {
|
while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == Root) {
|
||||||
@@ -33,7 +33,7 @@ namespace Orchard.Projections.Settings.Serialization {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadElement(XmlReader reader, SObject parent) {
|
private void ReadElement(XmlReader reader, Bag parent) {
|
||||||
var name = XmlConvert.DecodeName(reader.LocalName);
|
var name = XmlConvert.DecodeName(reader.LocalName);
|
||||||
var type = reader["type"];
|
var type = reader["type"];
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ namespace Orchard.Projections.Settings.Serialization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var grappe = new SObject();
|
var grappe = new Bag();
|
||||||
reader.Read();
|
reader.Read();
|
||||||
parent.SetMember(name, grappe);
|
parent.SetMember(name, grappe);
|
||||||
while (reader.MoveToContent() == XmlNodeType.Element) {
|
while (reader.MoveToContent() == XmlNodeType.Element) {
|
||||||
@@ -66,7 +66,7 @@ namespace Orchard.Projections.Settings.Serialization {
|
|||||||
var list = new List<object>();
|
var list = new List<object>();
|
||||||
reader.Read();
|
reader.Read();
|
||||||
while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "Item") {
|
while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "Item") {
|
||||||
dynamic o = new SObject();
|
dynamic o = new Bag();
|
||||||
ReadElement(reader, o);
|
ReadElement(reader, o);
|
||||||
list.Add(o.Item);
|
list.Add(o.Item);
|
||||||
}
|
}
|
||||||
@@ -74,16 +74,16 @@ namespace Orchard.Projections.Settings.Serialization {
|
|||||||
return new SArray(list.ToArray());
|
return new SArray(list.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteGrappe(XmlWriter writer, SObject grappe) {
|
private void WriteGrappe(XmlWriter writer, Bag grappe) {
|
||||||
foreach (var pair in grappe._properties) {
|
foreach (var pair in grappe._properties) {
|
||||||
WriteAny(writer, pair.Key, pair.Value);
|
WriteAny(writer, pair.Key, pair.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteAny(XmlWriter writer, string name, object value) {
|
private void WriteAny(XmlWriter writer, string name, object value) {
|
||||||
if (value is SObject) {
|
if (value is Bag) {
|
||||||
writer.WriteStartElement(XmlConvert.EncodeLocalName(name));
|
writer.WriteStartElement(XmlConvert.EncodeLocalName(name));
|
||||||
WriteGrappe(writer, (SObject)value);
|
WriteGrappe(writer, (Bag)value);
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement();
|
||||||
}
|
}
|
||||||
if (value is SArray) {
|
if (value is SArray) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace Orchard.Projections.Settings {
|
namespace Orchard.Data.Bags {
|
||||||
public class SettingsValueProvider : IValueProvider {
|
public class SettingsValueProvider : IValueProvider {
|
||||||
private readonly dynamic _state;
|
private readonly dynamic _state;
|
||||||
|
|
||||||
Reference in New Issue
Block a user