Browse Source

WrapExtensions

master
wwwk 3 years ago
parent
commit
1cc38bd0f4
  1. 15
      modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs
  2. 27
      modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Mvc/ActionContextExtensions.cs
  3. 5
      modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe.Abp.AspNetCore.Mvc.Wrapper.csproj

15
modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Cors/AbpCorsPolicyBuilderExtensions.cs

@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Cors.Infrastructure;
using Sanhe.Abp.Wrapper;
namespace Microsoft.AspNetCore.Cors;
public static class AbpCorsPolicyBuilderExtensions
{
public static CorsPolicyBuilder WithAbpWrapExposedHeaders(this CorsPolicyBuilder corsPolicyBuilder)
{
return corsPolicyBuilder
.WithExposedHeaders(
AbpHttpWrapConsts.AbpWrapResult,
AbpHttpWrapConsts.AbpDontWrapResult);
}
}

27
modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Microsoft/AspNetCore/Mvc/ActionContextExtensions.cs

@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Controllers;
using Sanhe.Abp.Wrapper;
namespace Microsoft.AspNetCore.Mvc;
public static class ActionContextExtensions
{
public static bool CanWarpRsult(this ActionDescriptor actionDescriptor)
{
if (actionDescriptor is ControllerActionDescriptor descriptor)
{
if (descriptor.MethodInfo.IsDefined(typeof(IgnoreWrapResultAttribute), true))
{
return false;
}
if (descriptor.ControllerTypeInfo.IsDefined(typeof(IgnoreWrapResultAttribute), true))
{
return false;
}
return true;
}
return false;
}
}

5
modules/mvc/Sanhe.Abp.AspNetCore.Mvc.Wrapper/Sanhe.Abp.AspNetCore.Mvc.Wrapper.csproj

@ -26,9 +26,4 @@
<ProjectReference Include="..\..\common\Sanhe.Abp.Wrapper\Sanhe.Abp.Wrapper.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Microsoft\AspNetCore\Cors\" />
<Folder Include="Microsoft\AspNetCore\Mvc\" />
</ItemGroup>
</Project>

Loading…
Cancel
Save