当前位置: 首页>>代码示例>>C#>>正文


C# ControllerContext.GetWorkContext方法代码示例

本文整理汇总了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)));
        }
开发者ID:RasterImage,项目名称:Orchard,代码行数:13,代码来源:OrchardFilterProvider.cs

示例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));
 }
开发者ID:jdages,项目名称:AndrewsHouse,代码行数:5,代码来源:OrchardFilterProvider.cs

示例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();
        }
开发者ID:BedeGaming,项目名称:IDeliverable.Widgets,代码行数:49,代码来源:WidgetOutputCacheFilter.cs

示例4: Resolve

 public static Localizer Resolve(ControllerContext controllerContext, string scope)
 {
     var workContext = controllerContext.GetWorkContext();
     return Resolve(workContext, scope);
 }
开发者ID:qhme,项目名称:OrchardLite,代码行数:5,代码来源:LocalizationUtilities.cs


注:本文中的System.Web.Mvc.ControllerContext.GetWorkContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。