File: PersonWrapper.cs
Web Access
Project: src\src\Mvc\Mvc.Formatters.Xml\test\Microsoft.AspNetCore.Mvc.Formatters.Xml.Test.csproj (Microsoft.AspNetCore.Mvc.Formatters.Xml.Test)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Globalization;
 
namespace Microsoft.AspNetCore.Mvc.Formatters.Xml;
 
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(CultureInfo.InvariantCulture, "{0}, {1}, {2}", Id, Name, Age);
    }
 
    public object Unwrap(Type declaredType)
    {
        return new Person() { Id = this.Id, Name = this.Name };
    }
}