mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 01:57:55 +08:00
Reverting changes to WorkContextImplementation
--HG-- branch : 1.x
This commit is contained in:
@@ -8,7 +8,6 @@ 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 ConcurrentDictionary<string, object> _states = new ConcurrentDictionary<string, object>();
|
|
||||||
readonly IEnumerable<IWorkContextStateProvider> _workContextStateProviders;
|
readonly IEnumerable<IWorkContextStateProvider> _workContextStateProviders;
|
||||||
|
|
||||||
public WorkContextImplementation(IComponentContext componentContext) {
|
public WorkContextImplementation(IComponentContext componentContext) {
|
||||||
@@ -25,10 +24,8 @@ namespace Orchard.Environment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override T GetState<T>(string name) {
|
public override T GetState<T>(string name) {
|
||||||
return (T)_states.GetOrAdd(name, (x) => {
|
var resolver = _stateResolvers.GetOrAdd(name, FindResolverForState<T>);
|
||||||
var resolver = _stateResolvers.GetOrAdd(x, FindResolverForState<T>);
|
return (T)resolver();
|
||||||
return resolver();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Func<object> FindResolverForState<T>(string name) {
|
Func<object> FindResolverForState<T>(string name) {
|
||||||
@@ -42,7 +39,7 @@ namespace Orchard.Environment {
|
|||||||
|
|
||||||
|
|
||||||
public override void SetState<T>(string name, T value) {
|
public override void SetState<T>(string name, T value) {
|
||||||
_stateResolvers[name] = () => _states[name] = value;
|
_stateResolvers[name] = () => value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user