ParseExpression() public static method

public static ParseExpression ( string expression ) : System.Web.Compilation.ResourceExpressionFields
expression string
return System.Web.Compilation.ResourceExpressionFields
        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);
        }
示例#2
0
        public static string GetResourceByName(string fieldResourceName, string virtualPath)
        {
            string result = string.Empty;

            var context = new ExpressionBuilderContext(virtualPath);
            var builder = new ResourceExpressionBuilder();

            try
            {
                var fields =
                    (ResourceExpressionFields)builder.ParseExpression(fieldResourceName, typeof(string), context);
                result =
                    (string)
                        HttpContext.GetLocalResourceObject(virtualPath, fields.ResourceKey, CultureInfo.CurrentCulture);
            }
            catch (Exception e)
            {
                result = "The field underfined";
            }
            return result;
        }
示例#3
0
 /// <summary>
 /// Gets a resource fields.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="virtualPath">The virtual path.</param>
 /// <returns>The resource fields.</returns>
 private static ResourceExpressionFields GetResourceFields(string expression, string virtualPath)
 {
     var context = new ExpressionBuilderContext(virtualPath);
     var builder = new ResourceExpressionBuilder();
     return (ResourceExpressionFields)builder.ParseExpression(expression, typeof(string), context);
 }