mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Update WorkContextImplementation.cs
This commit is contained in:
@@ -8,11 +8,11 @@ namespace Orchard.Environment {
|
|||||||
class WorkContextImplementation : WorkContext {
|
class WorkContextImplementation : WorkContext {
|
||||||
readonly IComponentContext _componentContext;
|
readonly IComponentContext _componentContext;
|
||||||
readonly ConcurrentDictionary<string, Func<object>> _stateResolvers = new ConcurrentDictionary<string, Func<object>>();
|
readonly ConcurrentDictionary<string, Func<object>> _stateResolvers = new ConcurrentDictionary<string, Func<object>>();
|
||||||
readonly IEnumerable<IWorkContextStateProvider> _workContextStateProviders;
|
readonly IEnumerable<Lazy<IWorkContextStateProvider>> _workContextStateProviders;
|
||||||
|
|
||||||
public WorkContextImplementation(IComponentContext componentContext) {
|
public WorkContextImplementation(IComponentContext componentContext) {
|
||||||
_componentContext = componentContext;
|
_componentContext = componentContext;
|
||||||
_workContextStateProviders = componentContext.Resolve<IEnumerable<IWorkContextStateProvider>>();
|
_workContextStateProviders = componentContext.Resolve<IEnumerable<Lazy<IWorkContextStateProvider>>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override T Resolve<T>() {
|
public override T Resolve<T>() {
|
||||||
@@ -29,7 +29,7 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Func<object> FindResolverForState<T>(string name) {
|
Func<object> FindResolverForState<T>(string name) {
|
||||||
var resolver = _workContextStateProviders.Select(wcsp => wcsp.Get<T>(name)).FirstOrDefault(value => !Equals(value, default(T)));
|
var resolver = _workContextStateProviders.Select(wcsp => wcsp.Value.Get<T>(name)).FirstOrDefault(value => !Equals(value, default(T)));
|
||||||
|
|
||||||
if (resolver == null) {
|
if (resolver == null) {
|
||||||
return () => default(T);
|
return () => default(T);
|
||||||
@@ -42,4 +42,4 @@ namespace Orchard.Environment {
|
|||||||
_stateResolvers[name] = () => value;
|
_stateResolvers[name] = () => value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user