本文整理汇总了C#中System.Web.Mvc.ControllerContext.GetWorkContext方法的典型用法代码示例。如果您正苦于以下问题:C# ControllerContext.GetWorkContext方法的具体用法?C# ControllerContext.GetWorkContext怎么用?C# ControllerContext.GetWorkContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.ControllerContext
的用法示例。
在下文中一共展示了ControllerContext.GetWorkContext方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFilters
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) {
var workContext = controllerContext.GetWorkContext();
// Map IFilterProvider implementations to MVC Filter objects
// Need to provide order values since Filter objects of identical
// scope and order would run in undefined order.
// We create negative order values to avoid conflicts with other
// potential user-provided MVC Filter objects, which hopefully use
// positive order values. We do this by reversing the list and
// negating the index.
var filters = workContext.Resolve<IEnumerable<IFilterProvider>>();
return filters.Reverse().Select((filter, index) => new Filter(filter, FilterScope.Action, -(index + 1)));
}
示例2: GetFilters
public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor) {
var workContext = controllerContext.GetWorkContext();
var filterProviders = workContext.Resolve<IEnumerable<IFilterProvider>>();
return filterProviders.Select(x => new Filter(x, FilterScope.Action, null));
}
示例3: ComputeCacheKey
private string ComputeCacheKey(WidgetPart widgetPart, ControllerContext controllerContext)
{
var sb = new StringBuilder();
var workContext = controllerContext.GetWorkContext();
var theme = _themeManager.GetRequestTheme(controllerContext.RequestContext).Id;
var url = GetAbsoluteUrl(controllerContext);
var settings = GetCacheSettings(workContext);
var varyByHeaders = new HashSet<string>(settings.VaryByRequestHeaders);
// Different tenants with the same urls have different entries.
varyByHeaders.Add("HOST");
var queryString = controllerContext.RequestContext.HttpContext.Request.QueryString;
var requestHeaders = controllerContext.RequestContext.HttpContext.Request.Headers;
var parameters = new Dictionary<string, object>();
foreach (var key in queryString.AllKeys.Where(x => x != null))
{
parameters[key] = queryString[key];
}
foreach (var header in varyByHeaders)
{
if (requestHeaders.AllKeys.Contains(header))
{
parameters["HEADER:" + header] = requestHeaders[header];
}
}
sb.Append("layer=").Append(widgetPart.LayerId.ToString(CultureInfo.InvariantCulture)).Append(";");
sb.Append("zone=").Append(widgetPart.Zone).Append(";");
sb.Append("widget=").Append(widgetPart.Id.ToString(CultureInfo.InvariantCulture)).Append(";");
sb.Append("tenant=").Append(_shellSettings.Name).Append(";");
sb.Append("url=").Append(url.ToLowerInvariant()).Append(";");
if (settings.VaryByCulture)
{
sb.Append("culture=").Append(workContext.CurrentCulture.ToLowerInvariant()).Append(";");
}
sb.Append("theme=").Append(theme.ToLowerInvariant()).Append(";");
foreach (var pair in parameters)
{
sb.AppendFormat("{0}={1};", pair.Key.ToLowerInvariant(), Convert.ToString(pair.Value).ToLowerInvariant());
}
return sb.ToString();
}
示例4: Resolve
public static Localizer Resolve(ControllerContext controllerContext, string scope)
{
var workContext = controllerContext.GetWorkContext();
return Resolve(workContext, scope);
}