title: How can to map to a wrapper class using Mapster?
body: <p>Based on my project I need to create a wrapper for “IFormFile”, Actually I created a “AppFileProxy” class and “IAppFile” interface for this purpose  :</p>
  <p>IAppFile.cs :</p>
  <pre><code>public interface IAppFile
  {
      string Name { get; }
  
      string FileName { get; }
  
      string ContentType { get; }
  
      long Length { get; }
  
      void CopyTo(Stream target);
      Task CopyToAsync(Stream target, CancellationToken cancellationToken = default);
      Stream OpenReadStream();
  }
  </code></pre>
  <p>AppFileProxy.cs :</p>
  <pre><code>public class AppFileProxy : IAppFile
  {
      private readonly IFormFile _formFile;
  
      public AppFileProxy(IFormFile formFile)
      {
          _formFile = formFile ?? throw new ArgumentNullException(nameof(formFile));
      }
  
      public string Name =&gt; _formFile.Name;
  
      public string FileName =&gt; _formFile.FileName;
  
      public string ContentType =&gt; _formFile.ContentType;
  
      public long Length =&gt; _formFile.Length;
  
      public void CopyTo(Stream target)
      {
          _formFile.CopyTo(target);
      }
  
      public Task CopyToAsync(Stream target, CancellationToken cancellationToken = default)
      {
          return _formFile.CopyToAsync(target, cancellationToken);
      }
  
      public Stream OpenReadStream()
      {
          return _formFile.OpenReadStream();
      }
  }
  </code></pre>
  <p>Now, I want to Map “IFormFile” to “IAppFile” by using <strong>Mapster</strong> in the action controller as shown below :</p>
  <p>CompanyDto.cs :</p>
  <pre><code>public class CompanyDto
  {
      public string Name { get; set; }
      public IFormFile Logo { get; set; }
  }
  </code></pre>
  <p>CompanyMapDto.cs :</p>
  <pre><code>public class CompanyMapDto : IRegister
  {
      public int Id { get; set; }
      public string Name { get; set; }
  
      public IAppFile Logo { get; set; }
  
      public void Register(TypeAdapterConfig config)
      {
          config.ForType&lt;CompanyDto, CompanyMapDto&gt;()
                  .Map(dest =&gt; dest.Logo, src =&gt; new AppFileProxy(src.Logo));
      }
  }
  </code></pre>
  <p>action controller :</p>
  <pre><code>[HttpPost]
  [Route(&quot;[controller]/[action]&quot;)]
  public async Task&lt;IActionResult&gt; AddCompanyWithLogo([FromForm]CompanyDto dto)
  {
      CompanyMapDto company = dto.Adapt&lt;CompanyMapDto&gt;();
  
      var stream = company.Logo.OpenReadStream();
  
      return Ok();
  }
  </code></pre>
  <p>But When I call action I get exception error for <code>OpenReadStream()</code> method :</p>
  <pre><code>System.NotImplementedException: The method or operation is not implemented.
     at GeneratedType_1.OpenReadStream()
     at MapsterInDotNet.Controllers.CompaniesController.AddCompanyWithLogo(CompanyDto dto) in C:\Users\Mohsen\source\repos\UseMapsterInDotNet\MapsterInDotNet\MapsterInDotNet\Controllers\CompaniesController.cs:line 52
     at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeActionMethodAsync&gt;g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeNextActionFilterAsync&gt;g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State&amp; next, Scope&amp; scope, Object&amp; state, Boolean&amp; isCompleted)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.&lt;InvokeInnerFilterAsync&gt;g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeFilterPipelineAsync&gt;g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeAsync&gt;g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
     at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeAsync&gt;g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
     at Microsoft.AspNetCore.Routing.EndpointMiddleware.&lt;Invoke&gt;g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
     at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
     at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
     at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
     at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/BIJP2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BIJP2.png" alt="enter image description here" /></a></p>
  <p>How do I resolve this?</p>