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


C# HttpContextBase.GetGlobalResourceObject方法代码示例

本文整理汇总了C#中System.Web.HttpContextBase.GetGlobalResourceObject方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContextBase.GetGlobalResourceObject方法的具体用法?C# HttpContextBase.GetGlobalResourceObject怎么用?C# HttpContextBase.GetGlobalResourceObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpContextBase的用法示例。


在下文中一共展示了HttpContextBase.GetGlobalResourceObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetInvalidPropertyValueResource

 private static string GetInvalidPropertyValueResource(HttpContextBase httpContext)
 {
     string str = (string)null;
     if (!string.IsNullOrEmpty(ValidationExtensions.ResourceClassKey) && httpContext != null)
         str = httpContext.GetGlobalResourceObject(ValidationExtensions.ResourceClassKey, "InvalidPropertyValue", CultureInfo.CurrentUICulture) as string;
     return str;
 }
开发者ID:michal-franc,项目名称:ElearnServices,代码行数:7,代码来源:Validation.cs

示例2: GetResourceString

        internal static string GetResourceString(HttpContextBase httpContext,
                                                string expression,
                                                string virtualPath,
                                                object[] args)

        {
            ExpressionBuilderContext context = new ExpressionBuilderContext(virtualPath);

            ResourceExpressionBuilder builder = new ResourceExpressionBuilder();

            ResourceExpressionFields fields = (ResourceExpressionFields) builder
                                                                             .ParseExpression(expression,
                                                                                              typeof (string), context);


            if (!string.IsNullOrEmpty(fields.ClassKey))

                return string.Format((string) httpContext.GetGlobalResourceObject(
                                                  fields.ClassKey,
                                                  fields.ResourceKey,
                                                  CultureInfo.CurrentUICulture),
                                     args);


            return string.Format((string) httpContext.GetLocalResourceObject(
                                              virtualPath,
                                              fields.ResourceKey,
                                              CultureInfo.CurrentUICulture),
                                 args);
        }
开发者ID:olivierdagenais,项目名称:testoriented,代码行数:30,代码来源:LocalizationExtensions.cs

示例3: GetResourceString

        private static string GetResourceString(HttpContextBase httpContext, string classKey, string resourceKey)
        {
            string value = httpContext.GetGlobalResourceObject(classKey, resourceKey) as string;

            if (string.IsNullOrEmpty(value))
            {
                string message = string.Format("Translation missing for key '{0}' in bundle '{1}' for culture '{2}'.", resourceKey, classKey, Thread.CurrentThread.CurrentCulture);
                throw new ResourceNotFoundException(message);
            }

            return value;
        }
开发者ID:beardeddev,项目名称:fuse,代码行数:12,代码来源:ResourceExtensions.cs

示例4: GetResourceString

        private static string GetResourceString(HttpContextBase httpContext, string expression, string virtualPath, object[] args)
        {
            string result;
            var identity = SqlResourceProvider.GetClassKey(expression);
            if (identity.ClassKey != null)
                result = (string)httpContext.GetGlobalResourceObject(identity.ClassKey, identity.ResourceKey, CultureInfo.CurrentUICulture);
            else
                result = (string)httpContext.GetLocalResourceObject(virtualPath, identity.ResourceKey, CultureInfo.CurrentUICulture);

            return args.Length > 0
                ? string.Format(result, args)
                : result;
        }
开发者ID:fbdegroot,项目名称:Core,代码行数:13,代码来源:Extensions.cs

示例5: GetResourceString

        /// <summary>
        /// Gets resource String using specified scope, key and culture.
        /// </summary>
        /// <remarks>
        /// <paramref name="translationMissing"/> handler will be called if resource can not be found.
        /// </remarks>
        /// <param name="context">The http context.</param>
        /// <param name="key">The resource key.</param>
        /// <param name="scope">The localization scope.</param>
        /// <param name="culture">The culture.</param>
        /// <param name="translationMissing">Translation missing fallback.</param>
        /// <returns>Localized String or <paramref name="translationMissing"/> result.</returns>
        public static String GetResourceString(HttpContextBase context, String key, String scope, CultureInfo culture, Func<String, String, String, String> translationMissing)
        {
            if (culture == null)
            {
                culture = CultureHelper.DefaultCulture;
            }

            var result = context.GetGlobalResourceObject(scope, key, culture) as String;
            if (result == null && translationMissing != null)
            {
                result = translationMissing(key, scope, culture.Name);
            }

            return result;
        }
开发者ID:coreframework,项目名称:Core-Framework,代码行数:27,代码来源:ResourceHelper.cs

示例6: GetInvalidPropertyValueResource

        private static string GetInvalidPropertyValueResource(HttpContextBase httpContext)
        {
            string message = null;
            if (!string.IsNullOrEmpty(System.Web.Mvc.Html.ValidationExtensions.ResourceClassKey) && httpContext != null)
                message = httpContext.GetGlobalResourceObject(System.Web.Mvc.Html.ValidationExtensions.ResourceClassKey, "InvalidPropertyValue", CultureInfo.CurrentUICulture) as string;

            return message ?? "The value '{0}' is invalid.";
        }
开发者ID:modulexcite,项目名称:FluentHtml,代码行数:8,代码来源:ValidationMessage.cs

示例7: GetInvalidPropertyValueResource

 private static string GetInvalidPropertyValueResource(HttpContextBase httpContext)
 {
     string str = null;
     if (!string.IsNullOrEmpty(System.Web.Mvc.Html.ValidationExtensions.ResourceClassKey) && (httpContext != null))
     {
         str = httpContext.GetGlobalResourceObject(System.Web.Mvc.Html.ValidationExtensions.ResourceClassKey, "InvalidPropertyValue", CultureInfo.CurrentUICulture) as string;
     }
     return (str ?? SR.GetString("Common_ValueNotValidForProperty"));
 }
开发者ID:jason1234,项目名称:CMS,代码行数:9,代码来源:ValidationExtensions.cs

示例8: GetInvalidPropertyValueResource

 private static string GetInvalidPropertyValueResource(HttpContextBase httpContext)
 {
   string resourceValue = null;
   if (!String.IsNullOrEmpty(ResourceClassKey) && (httpContext != null))
   {
     // If the user specified a ResourceClassKey try to load the resource they specified.
     // If the class key is invalid, an exception will be thrown.
     // If the class key is valid but the resource is not found, it returns null, in which
     // case it will fall back to the MVC default error message.
     resourceValue = httpContext.GetGlobalResourceObject(ResourceClassKey, "InvalidPropertyValue", CultureInfo.CurrentUICulture) as string;
   }
   return resourceValue ?? "Invalid value";
 }
开发者ID:nahmedsoftsource,项目名称:framework-abdh,代码行数:13,代码来源:FluentHtmlExtensions.cs


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