本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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.";
}
示例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"));
}
示例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";
}