mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 19:04:51 +08:00
Implement WorkContent.HttpContext
Work Item: 17008 --HG-- branch : 1.x
This commit is contained in:
19
src/Orchard/Mvc/HttpContextWorkContext.cs
Normal file
19
src/Orchard/Mvc/HttpContextWorkContext.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace Orchard.Mvc {
|
||||
public class HttpContextWorkContext : IWorkContextStateProvider {
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public HttpContextWorkContext(IHttpContextAccessor httpContextAccessor) {
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public Func<WorkContext, T> Get<T>(string name) {
|
||||
if (name == "HttpContext") {
|
||||
var result = (T)(object)_httpContextAccessor.Current();
|
||||
return ctx => result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -183,6 +183,7 @@
|
||||
<Compile Include="Localization\Services\ILocalizedStringManager.cs" />
|
||||
<Compile Include="Logging\OrchardFileAppender.cs" />
|
||||
<Compile Include="Messaging\Services\DefaultMessageManager.cs" />
|
||||
<Compile Include="Mvc\HttpContextWorkContext.cs" />
|
||||
<Compile Include="Mvc\Extensions\ControllerExtensions.cs" />
|
||||
<Compile Include="Mvc\IOrchardViewPage.cs" />
|
||||
<Compile Include="Mvc\ShapeResult.cs" />
|
||||
|
Reference in New Issue
Block a user