Removing FuncDictionary

--HG--
branch : autoroute
This commit is contained in:
Sebastien Ros
2012-01-24 17:36:27 -08:00
parent 8462406480
commit a8876e6d72
3 changed files with 4 additions and 40 deletions

View File

@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Web.Routing;
using System;
namespace Orchard.ContentManagement {
public class ContentItemMetadata {
@@ -11,7 +11,7 @@ namespace Orchard.ContentManagement {
}
public string DisplayText { get; set; }
public ContentIdentity Identity { get; set; }
public RouteValueDictionary DisplayRouteValues { get { return RouteValues.Get("Display"); } set { RouteValues.Set("Display",()=>value); } }
public RouteValueDictionary DisplayRouteValues { get; set; }
public RouteValueDictionary EditorRouteValues { get; set; }
public RouteValueDictionary CreateRouteValues { get; set; }
public RouteValueDictionary RemoveRouteValues { get; set; }
@@ -19,8 +19,9 @@ namespace Orchard.ContentManagement {
get { return _adminRouteValues ?? EditorRouteValues; }
set { _adminRouteValues = value; }
}
public readonly IDictionary<string, Func<RouteValueDictionary>> RouteValues = new Dictionary<string, Func<RouteValueDictionary>>();
public readonly IList<GroupInfo> DisplayGroupInfo = new List<GroupInfo>();
public readonly IList<GroupInfo> EditorGroupInfo = new List<GroupInfo>();
public readonly FuncDictionary<string, RouteValueDictionary> RouteValues = new FuncDictionary<string, RouteValueDictionary>();
}
}

View File

@@ -1,36 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Orchard.ContentManagement {
public class FuncDictionary<TKey, TVal> {
private readonly IDictionary<TKey, TVal> _cached;
private readonly IDictionary<TKey, Func<TVal>> _factories;
public FuncDictionary() {
_cached = new Dictionary<TKey, TVal>();
_factories = new Dictionary<TKey, Func<TVal>>();
}
public TVal Get(TKey key) {
if (!_cached.ContainsKey(key)) {
if (!_factories.ContainsKey(key)) return default(TVal);
_cached[key] = _factories[key]();
}
return _cached[key];
}
public void Set(TKey key, Func<TVal> factory) {
_cached.Remove(key);
_factories[key] = factory;
}
public void Remove(TKey key) {
_cached.Remove(key);
_factories.Remove(key);
}
}
}

View File

@@ -165,7 +165,6 @@
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
<Compile Include="ContentManagement\DefaultHqlQuery.cs" />
<Compile Include="ContentManagement\FuncDictionary.cs" />
<Compile Include="ContentManagement\Handlers\UpdateContentContext.cs" />
<Compile Include="ContentManagement\IHqlExpression.cs" />
<Compile Include="ContentManagement\IHqlQuery.cs" />