ContentItemMetadata has a string dictionary

--HG--
branch : autoroute
This commit is contained in:
randompete
2012-01-21 20:41:56 +00:00
parent 1ca8a7b0cc
commit 84a64768f5
3 changed files with 40 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Web.Routing;
using System;
namespace Orchard.ContentManagement {
public class ContentItemMetadata {
@@ -10,7 +11,7 @@ namespace Orchard.ContentManagement {
}
public string DisplayText { get; set; }
public ContentIdentity Identity { get; set; }
public RouteValueDictionary DisplayRouteValues { get; set; }
public RouteValueDictionary DisplayRouteValues { get { return RouteValues.Get("Display"); } set { RouteValues.Set("Display",()=>value); } }
public RouteValueDictionary EditorRouteValues { get; set; }
public RouteValueDictionary CreateRouteValues { get; set; }
public RouteValueDictionary RemoveRouteValues { get; set; }
@@ -20,5 +21,6 @@ namespace Orchard.ContentManagement {
}
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

@@ -0,0 +1,36 @@
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,6 +165,7 @@
<Compile Include="ContentManagement\ContentItemBehavior.cs" />
<Compile Include="ContentManagement\ContentPartBehavior.cs" />
<Compile Include="ContentManagement\DefaultHqlQuery.cs" />
<Compile Include="ContentManagement\FuncDictionary.cs" />
<Compile Include="ContentManagement\IHqlExpression.cs" />
<Compile Include="ContentManagement\IHqlQuery.cs" />
<Compile Include="ContentManagement\Handlers\DescribeMembersContext.cs" />