我有以下课程
public class MenuVeiculo
{
public string Nome { get; set; }
public string NomeEn { get; set; }
public Guid ID { get; set; }
}
如您所见,我有两个属性,“Nome”和“NomeEn”。每一个代表名字和英文名字。
mvc.sitemap
<mvcSiteMapNode key="MenuVeiculo" dynamicNodeProvider="Semep.Extensibilidade.SiteMap.MenuVeiculoDynamicNodeProvider, Semep" title="Menu veiculo" action="Index" controller="Rental">
MenuVeiculoDynamicNodeProvider.cs
public class MenuVeiculoDynamicNodeProvider : DynamicNodeProviderBase
{
public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
{
var context = DependencyResolver.Current.GetService<SemepContext>();
var listDB = (from p in context.MenusVeiculo
select new
{
p.Nome,
p.ID
});
const string keyFormat = "MenuVeiculo_{0}";
foreach (var menu in listDB.ToList())
{
var key = string.Format(keyFormat, menu.ID.ToString().ToUpper());
var root = new DynamicNode(key, menu.Nome)
{
Title = menu.Nome
,
Key = key
};
root.Attributes.Add("id", menu.ID.ToString());
root.RouteValues.Add("id", menu.ID);
yield return root;
}
}
#endregion
}
问题
我的问题是,如何使用多语言和 DynamicNodeProviderBase?如您所见,有两个字段,我只显示一个。“Thread.CurrentThread.CurrentCulture”的一个问题是MvcSiteMapProvider缓存了结果,如何处理: