Skip to content

Commit

Permalink
Added ordering to parameterized content members.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-E-angelo authored and Mike-EEE committed Jan 18, 2020
1 parent 4f84d01 commit 9a5b3a9
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public ConstructorMembers(IMembers members, IMemberLocators locator, IMemberSpec
) // Turning into a game of Jenga here.
{
var result = source.Select(x => x.Name)
.Select(_locator.Get(type)
.Get)
.Select(_locator.Get(type).Get)
.Where(x => x.HasValue)
.Select(x => x.Value)
.Select(_members.Get)
.Where(_member)
.OrderBy(x => x.Order)
.Select(x => new ParameterizedMember(x))
.ToImmutableArray<IMember>();
if (result.Length == source.Length)
Expand Down
70 changes: 70 additions & 0 deletions test/ExtendedXmlSerializer.Tests.ReportedIssues/Issue355Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using ExtendedXmlSerializer.Configuration;
using ExtendedXmlSerializer.Tests.ReportedIssues.Support;
using Xunit;

namespace ExtendedXmlSerializer.Tests.ReportedIssues
{
public sealed class Issue355Tests
{
[Fact]
void Verify()
{
var container = ConfiguredContainer.New<CombinedProfile>();
var serializer = container.UseOptimizedNamespaces()
.EnableParameterizedContent()
.EnableImplicitTyping(typeof(Outer))
//

.Create()
.ForTesting();

serializer.Assert(new Outer("A", "B", "C"), @"<?xml version=""1.0"" encoding=""utf-8""?><OuterDataThings><Cc>C</Cc><Bb>B</Bb><Aa>A</Aa></OuterDataThings>");
}

public class Outer
{
public Outer(string a, string b, string c)
{
A = a;
B = b;
C = c;
}

public string C { get; }

public string B { get; }

public string A { get; }
}

sealed class CombinedProfile : CompositeConfigurationProfile
{
public static CombinedProfile Default { get; } = new CombinedProfile();

CombinedProfile() : base(OuterProfile.Default) {}
}

sealed class OuterProfile : IConfigurationProfile
{
public static OuterProfile Default { get; } = new OuterProfile();

OuterProfile() {}

public IConfigurationContainer Get(IConfigurationContainer parameter)
=> parameter.Type<Outer>()
.Name("OuterDataThings")
//
.Member(x => x.C)
.Name("Cc")
.Order(0)
//
.Member(x => x.B)
.Name("Bb")
.Order(1)
//
.Member(x => x.A)
.Name("Aa")
.Order(2);
}
}
}

0 comments on commit 9a5b3a9

Please sign in to comment.