aspnetcore/test/Microsoft.AspNetCore.Mvc.Fo.../Internal/PersonWrapper.cs

35 lines
868 B
C#

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.AspNetCore.Mvc.Formatters.Xml.Internal
{
public class PersonWrapper : IUnwrappable
{
public PersonWrapper() { }
public PersonWrapper(Person person)
{
Id = person.Id;
Name = person.Name;
Age = 35;
}
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
public override string ToString()
{
return string.Format("{0}, {1}, {2}", Id, Name, Age);
}
public object Unwrap(Type declaredType)
{
return new Person() { Id = this.Id, Name = this.Name };
}
}
}