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);
        }
        public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
        {
            // This code is also copied in ConnectionStringsExpressionEditor.ParseExpression()
            const string connectionStringSuffix = ".connectionstring";
            const string providerNameSuffix     = ".providername";
            string       name             = String.Empty;
            bool         connectionString = true;

            if (expression != null)
            {
                if (expression.EndsWith(connectionStringSuffix, StringComparison.OrdinalIgnoreCase))
                {
                    name = expression.Substring(0, expression.Length - connectionStringSuffix.Length);
                }
                else
                {
                    if (expression.EndsWith(providerNameSuffix, StringComparison.OrdinalIgnoreCase))
                    {
                        connectionString = false;
                        name             = expression.Substring(0, expression.Length - providerNameSuffix.Length);
                    }
                    else
                    {
                        name = expression;
                    }
                }
            }

            return(new Pair(name, connectionString));
        }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            if (!entry.Expression.Contains(","))
              {
            throw new ArgumentException("Must include two numbers separated by a comma.");
              }
              else
              {
            // get two numbers
            string[] numbers = entry.Expression.Split(',');
            if (numbers.Length != 2)
            {
              throw new ArgumentException("Only include two numbers");
            }
            else
            {
              int lowerLimit, upperLimit;
              if (Int32.TryParse(numbers[0], out lowerLimit) && Int32.TryParse(numbers[1], out upperLimit))
              {
            CodeTypeReferenceExpression typeRef = new CodeTypeReferenceExpression(this.GetType());
            CodeExpression[] methodParameters = new CodeExpression[2];
            methodParameters[0] = new CodePrimitiveExpression(lowerLimit);
            methodParameters[1] = new CodePrimitiveExpression(upperLimit);

            return new CodeMethodInvokeExpression(typeRef, "GetRandomNumber", methodParameters);
              }
              else
              {
            throw new ArgumentException("Use valid Integers");
              }
            }
              }
        }
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     var fields = parsedData as ResourceExpressionFields;
     EnsureResourceProviderFactory();
     IResourceProvider provider = _resourceProviderFactory.CreateGlobalResourceProvider(fields.ClassKey);
     return provider.GetObject(fields.ResourceKey, null);
 }
 internal void ParseExpression(ExpressionBuilderContext context)
 {
     if (((this.Expression != null) && (this.ExpressionPrefix != null)) && (this.ExpressionBuilder != null))
     {
         this._parsedExpressionData = this.ExpressionBuilder.ParseExpression(this.Expression, base.Type, context);
     }
 }
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     if ((entry.DeclaringType == null) || (entry.PropertyInfo == null))
     {
         return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", new CodeExpression[] { new CodePrimitiveExpression(entry.Expression.Trim()) });
     }
     return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", new CodeExpression[] { new CodePrimitiveExpression(entry.Expression.Trim()), new CodeTypeOfExpression(entry.DeclaringType), new CodePrimitiveExpression(entry.PropertyInfo.Name) });
 }
 public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     return new CodeMethodInvokeExpression(
         new CodeTypeReferenceExpression(typeof(WebManager) ),
         "GetLabel",
         new CodePrimitiveExpression( entry.Expression.Trim() ),
         new CodePrimitiveExpression( context.VirtualPath ));
 }
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     if (target is Control)
     {
         return GetRouteValue(context.TemplateControl.Page, entry.Expression.Trim(), entry.ControlType, entry.Name);
     }
     return null;
 }
        /// <summary>
        /// Gets the code expression.
        /// </summary>
        /// <param name="entry">
        /// The entry.
        /// </param>
        /// <param name="parsedData">
        /// The parsed data.
        /// </param>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <returns>
        /// A CodeExpression.
        /// </returns>
        public override CodeExpression GetCodeExpression(
            BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            var typeName = BeforeLast(entry.Expression, ".");
            var propertyName = AfterLast(entry.Expression, ".");

            return new CodePrimitiveExpression(PropertyLength(typeName, propertyName));
        }
 public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     return new CodeMethodInvokeExpression(
         new CodeTypeReferenceExpression(typeof(WebManager) ),
         "GetService",
         new CodePrimitiveExpression( entry.Expression.Trim() ),
         new CodeTypeOfExpression( new CodeTypeReference(entry.PropertyInfo.PropertyType ) ) );
 }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            string property = (string) parsedData;

            CodePrimitiveExpression prim = new CodePrimitiveExpression(property);
            CodeExpression[] args = new[] {prim};
            CodeTypeReferenceExpression refType = new CodeTypeReferenceExpression(this.GetType());
            return new CodeMethodInvokeExpression(refType, "GetProperty", args);
        }
示例#12
0
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
                                                  object parsedData, ExpressionBuilderContext context)
 {
     return(new CodeMethodInvokeExpression(
                new CodeTypeReferenceExpression(this.GetType()),
                "GetRouteUrl",
                new CodeThisReferenceExpression(),
                new CodePrimitiveExpression(entry.Expression.Trim())));
 }
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     ResourceExpressionFields fields = (ResourceExpressionFields) parsedData;
     if (fields.ClassKey.Length == 0)
     {
         return this.GetPageResCodeExpression(fields.ResourceKey, entry);
     }
     return this.GetAppResCodeExpression(fields.ClassKey, fields.ResourceKey, entry);
 }
示例#14
0
 public override CodeExpression GetCodeExpression(
     BoundPropertyEntry entry,
     object parsedData,
     ExpressionBuilderContext context)
 {
     CodeMethodInvokeExpression ex = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(ResourceReader)),
     "GetVal", new CodePrimitiveExpression(entry.Expression.ToString().Trim()));
     return ex;
 }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
            object parsedData, ExpressionBuilderContext context) {

            return new CodeMethodInvokeExpression(
                new CodeTypeReferenceExpression(this.GetType()),
                "GetRouteUrl",
                new CodeThisReferenceExpression(),
                new CodePrimitiveExpression(entry.Expression.Trim()));
        }
示例#16
0
		// This method is used only from within pages that aren't compiled
		public override object EvaluateExpression (object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
		{
			if (entry == null)
				throw new NullReferenceException (".NET emulation (entry == null)");

			if (context == null)
				throw new NullReferenceException (".NET emulation (context == null)");
			
			return GetRouteUrl (context.TemplateControl, entry.Expression);
		}
 /// <summary>
 /// Returns a code expression to evaluate during page execution.
 /// </summary>
 /// <param name="entry">The property name of the object.</param>
 /// <param name="parsedData">The parsed value of the expression.</param>
 /// <param name="context">Properties for the control or page.</param>
 /// <returns>A CodeExpression that invokes a method.</returns>
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     var lsr = (LocaleStringResource)parsedData;
     var ex = new CodeMethodInvokeExpression(
         new CodeTypeReferenceExpression(base.GetType()),
         "GetVal",
         new CodePrimitiveExpression(lsr.ResourceName)
     );
     return ex;
 }
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     Pair pair = (Pair) parsedData;
     string first = (string) pair.First;
     if ((bool) pair.Second)
     {
         return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetConnectionString", new CodeExpression[] { new CodePrimitiveExpression(first) });
     }
     return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetConnectionStringProviderName", new CodeExpression[] { new CodePrimitiveExpression(first) });
 }
		public override CodeExpression GetCodeExpression (BoundPropertyEntry entry, object parsedData,
								  ExpressionBuilderContext context)
		{			
			Pair connString = parsedData as Pair;
			return new CodeMethodInvokeExpression (
				new CodeTypeReferenceExpression (typeof (ConnectionStringsExpressionBuilder)),
				(bool)connString.Second ? "GetConnectionStringProviderName" : "GetConnectionString",
				new CodeExpression [] {new CodePrimitiveExpression (connString.First)}
			);
		}
        public override object EvaluateExpression(object target, BoundPropertyEntry entry,
            object parsedData, ExpressionBuilderContext context) {

            // Target should always be a control
            Control control = target as Control;
            if (control == null) 
                return null;

            return GetRouteValue(context.TemplateControl.Page, entry.Expression.Trim(), entry.ControlType, entry.Name);
        }
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     ResourceExpressionFields fields = (ResourceExpressionFields) parsedData;
     IResourceProvider resourceProvider = GetResourceProvider(fields, context.VirtualPathObject);
     if (entry.Type == typeof(string))
     {
         return GetResourceObject(resourceProvider, fields.ResourceKey, null);
     }
     return GetResourceObject(resourceProvider, fields.ResourceKey, null, entry.DeclaringType, entry.PropertyInfo.Name);
 }
		public override Object ParseExpression(String expression, Type propertyType, ExpressionBuilderContext context)
		{
			if (String.IsNullOrWhiteSpace(expression) == true)
			{
				return (base.ParseExpression(expression, propertyType, context));
			}
			else
			{
				return (Convert(GetWebResourceUrl(expression), propertyType));
			}
		}
 /// <summary>
 /// When overridden in a derived class, returns code that is used during page execution to obtain the evaluated expression.
 /// </summary>
 /// <param name="entry">The object that represents information about the property bound to by the expression.</param>
 /// <param name="parsedData">The object containing parsed data as returned by <see cref="M:System.Web.Compilation.ExpressionBuilder.ParseExpression(System.String,System.Type,System.Web.Compilation.ExpressionBuilderContext)" />.</param>
 /// <param name="context">Contextual information for the evaluation of the expression.</param>
 /// <returns>
 /// A <see cref="T:System.CodeDom.CodeExpression" /> that is used for property assignment.
 /// </returns>
 public override CodeExpression GetCodeExpression( BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context )
 {
     // from http://msdn.microsoft.com/en-us/library/system.web.compilation.expressionbuilder.getcodeexpression.aspx
     Type type1 = entry.DeclaringType;
     PropertyDescriptor descriptor1 = TypeDescriptor.GetProperties( type1 )[entry.PropertyInfo.Name];
     CodeExpression[] expressionArray1 = new CodeExpression[3];
     expressionArray1[0] = new CodePrimitiveExpression( entry.Expression.Trim() );
     expressionArray1[1] = new CodeTypeOfExpression( type1 );
     expressionArray1[2] = new CodePrimitiveExpression( entry.Name );
     return new CodeCastExpression( descriptor1.PropertyType, new CodeMethodInvokeExpression( new CodeTypeReferenceExpression( base.GetType() ), "GetEvalData", expressionArray1 ) );
 }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData,
                                                         ExpressionBuilderContext context)
        {
            Pair connString = parsedData as Pair;

            return(new CodeMethodInvokeExpression(
                       new CodeTypeReferenceExpression(typeof(ConnectionStringsExpressionBuilder)),
                       (bool)connString.Second ? "GetConnectionStringProviderName" : "GetConnectionString",
                       new CodeExpression [] { new CodePrimitiveExpression(connString.First) }
                       ));
        }
		public override CodeExpression GetCodeExpression (BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
		{
			Type type = entry.DeclaringType;
			PropertyDescriptor descriptor = TypeDescriptor.GetProperties(type)[entry.PropertyInfo.Name];
			CodeExpression[] expressionArray = new CodeExpression[3];
			expressionArray[0] = new CodePrimitiveExpression(entry.Expression.Trim());
			expressionArray[1] = new CodeTypeOfExpression(entry.Type);
			expressionArray[2] = new CodePrimitiveExpression(entry.Name);
			return new CodeCastExpression(descriptor.PropertyType, new CodeMethodInvokeExpression(new 
								       CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", expressionArray));
		}
		public override Object EvaluateExpression(Object target, BoundPropertyEntry entry, Object parsedData, ExpressionBuilderContext context)
		{
			if (String.IsNullOrWhiteSpace(entry.Expression) == true)
			{
				return (base.EvaluateExpression(target, entry, parsedData, context));
			}
			else
			{
				return (Convert(GetThemeUrl(entry.Expression), entry.PropertyInfo.PropertyType));
			}
		}
		public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, Object parsedData, ExpressionBuilderContext context)
		{
			if (String.IsNullOrEmpty(entry.Expression) == true)
			{
				return (new CodePrimitiveExpression(String.Empty));
			}
			else
			{
				return (new CodeMethodInvokeExpression(new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(this.GetType()), "IsInGroup"), new CodePrimitiveExpression(entry.Expression)));
			}
		}
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     Pair pair = (Pair) parsedData;
     string first = (string) pair.First;
     bool second = (bool) pair.Second;
     ConnectionStringSettings settings1 = ConfigurationManager.ConnectionStrings[first];
     if (second)
     {
         return GetConnectionString(first);
     }
     return GetConnectionStringProviderName(first);
 }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            var inputParams = new CodeExpression[]
                                  {
                                      new CodePrimitiveExpression(entry.Expression.Trim()), 
                                      new CodeTypeOfExpression(entry.DeclaringType), 
                                      new CodePrimitiveExpression(entry.PropertyInfo.Name),
                                      new CodePrimitiveExpression(context.VirtualPath)
                                  };

            return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(GetType()), "GetLocalizedResource", inputParams);
        }
        public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            _log.Write(_id, SPTraceLogger.TraceSeverity.InformationEvent, "GetCodeExpression", "Info", "Called");

            CodeTypeReferenceExpression thisType = new CodeTypeReferenceExpression(base.GetType());

            CodePrimitiveExpression expression = new CodePrimitiveExpression(entry.Expression.Trim().ToString());

            string evaluationMethod = "GetKeyValue";

            return new CodeMethodInvokeExpression(thisType, evaluationMethod, new CodeExpression[] { expression });
        }
        ///<summary>
        /// 리소스 파일에서 값을 반환합니다.
        ///</summary>
        ///
        ///<returns>
        /// 구문 분석한 식과 관련된 <see cref="T:System.Object" />입니다. 구문 분석한 식은 클래스 이름과 리소스 키를 포함합니다.
        ///</returns>
        ///
        ///<param name="target">
        /// 식이 포함된 개체입니다.
        /// </param>
        ///<param name="entry">
        /// 식에 의해 바인딩된 속성에 대한 정보를 나타내는 개체입니다.
        /// </param>
        ///<param name="parsedData">
        /// <see cref="ParseExpression"/> 메서드에 의해 반환된 구문 분석한 데이터가 들어 있는 개체입니다.
        ///</param>
        ///<param name="context">
        /// 식을 계산하는 데 필요한 컨텍스트 정보입니다.
        ///</param>
        public override object EvaluateExpression(object target,
                                                  BoundPropertyEntry entry,
                                                  object parsedData,
                                                  ExpressionBuilderContext context) {
            if(IsDebugEnabled)
                log.Debug("표현식을 평가합니다... target=[{0}], entry=[{1}], parsedData=[{2}], context=[{3}]", target, entry, parsedData, context);

            var field = parsedData as ExpressionField;
            Guard.Assert(field != null, "파싱된 정보가 ExpressionField 형식이 아닙니다. parseData=[{0}]", parsedData);

            return ResourceProvider.GetObject(field.ClassKey, field.ResourceKey);
        }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            var expression = new CodeExpression[3];

            expression[0] = new CodePrimitiveExpression(entry.Expression.Trim());
            expression[1] = new CodeTypeOfExpression(typeof(string));
            expression[2] = new CodePrimitiveExpression(entry.Name);

            return new CodeCastExpression(typeof(string),
                                          new CodeMethodInvokeExpression(
                                              new CodeTypeReferenceExpression(GetType()), "GetEvalData",
                                              expression));
        }
 /// <summary>
 /// Returns an object that represents the parsed expression. 
 /// </summary>
 /// <param name="expression">The value of the declarative expression.</param>
 /// <param name="propertyType">The type of the property bound to by the expression.</param>
 /// <param name="context">Contextual information for the evaluation of the expression.</param>
 /// <returns>An Object that represents the parsed expression</returns>
 public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
 {
     LocaleStringResource lsr = new LocaleStringResource();
     lsr.ResourceName = expression;
     //try
     //{
     //    lsr.LanguageID = NopContext.Current.WorkingLanguage.LanguageID;
     //}
     //catch (Exception exc)
     //{
     //}
     return lsr;
 }
        public override object EvaluateExpression(object target, BoundPropertyEntry entry,
                                                  object parsedData, ExpressionBuilderContext context)
        {
            // Target should always be a control
            Control control = target as Control;

            if (control == null)
            {
                return(null);
            }

            return(GetRouteValue(context.TemplateControl.Page, entry.Expression.Trim(), entry.ControlType, entry.Name));
        }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
                                                         object parsedData, ExpressionBuilderContext context)
        {
            // Retrieve our parsed data
            ResourceExpressionFields fields = (ResourceExpressionFields)parsedData;

            // If there is no classKey, it's a page-level resource
            if (fields.ClassKey.Length == 0)
            {
                return(GetPageResCodeExpression(fields.ResourceKey, entry));
            }

            // Otherwise, it's a global resource
            return(GetAppResCodeExpression(fields.ClassKey, fields.ResourceKey, entry));
        }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
                                                         object parsedData, ExpressionBuilderContext context)
        {
            Pair   p                = (Pair)parsedData;
            string name             = (string)p.First;
            bool   connectionString = (bool)p.Second;

            if (connectionString)
            {
                return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(this.GetType()), "GetConnectionString", new CodePrimitiveExpression(name)));
            }
            else
            {
                return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(this.GetType()), "GetConnectionStringProviderName", new CodePrimitiveExpression(name)));
            }
        }
        public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
        {
            ResourceExpressionFields fields = null;

            try {
                fields = ParseExpressionInternal(expression);
            }
            catch {
            }

            // If the parsing failed for any reason throw an error
            if (fields == null)
            {
                throw new HttpException(
                          SR.GetString(SR.Invalid_res_expr, expression));
            }

            // The resource expression was successfully parsed. We now need to check whether
            // the resource object actually exists in the neutral culture

            // If we don't have a virtual path, we can't check that the resource exists.
            // This happens in the designer.
            if (context.VirtualPathObject != null)
            {
                IResourceProvider resourceProvider = GetResourceProvider(fields, VirtualPath.Create(context.VirtualPath));
                object            o = null;

                if (resourceProvider != null)
                {
                    try {
                        o = resourceProvider.GetObject(fields.ResourceKey, CultureInfo.InvariantCulture);
                    }
                    catch {}
                }

                // If it doesn't throw an exception
                if (o == null)
                {
                    throw new HttpException(
                              SR.GetString(SR.Res_not_found, fields.ResourceKey));
                }
            }

            return(fields);
        }
        public override object EvaluateExpression(object target, BoundPropertyEntry entry,
                                                  object parsedData, ExpressionBuilderContext context)
        {
            Pair   p                = (Pair)parsedData;
            string name             = (string)p.First;
            bool   connectionString = (bool)p.Second;

            ConnectionStringSettings setting = ConfigurationManager.ConnectionStrings[name];

            if (connectionString)
            {
                return(GetConnectionString(name));
            }
            else
            {
                return(GetConnectionStringProviderName(name));
            }
        }
        public override object EvaluateExpression(object target, BoundPropertyEntry entry,
                                                  object parsedData, ExpressionBuilderContext context)
        {
            // Retrieve our parsed data
            ResourceExpressionFields fields = (ResourceExpressionFields)parsedData;

            IResourceProvider resourceProvider = GetResourceProvider(fields, context.VirtualPathObject);

            if (entry.Type == typeof(string))
            {
                return(GetResourceObject(resourceProvider, fields.ResourceKey, null /*culture*/));
            }

            // If the property is not of type string, pass in extra information
            // so that the resource value will be converted to the right type
            return(GetResourceObject(resourceProvider, fields.ResourceKey, null /*culture*/,
                                     entry.DeclaringType, entry.PropertyInfo.Name));
        }
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
                                                  object parsedData, ExpressionBuilderContext context)
 {
     if (entry.DeclaringType == null || entry.PropertyInfo == null)
     {
         return(new CodeMethodInvokeExpression(
                    new CodeTypeReferenceExpression(this.GetType()),
                    "GetAppSetting",
                    new CodePrimitiveExpression(entry.Expression.Trim())));
     }
     else
     {
         return(new CodeMethodInvokeExpression(
                    new CodeTypeReferenceExpression(this.GetType()),
                    "GetAppSetting",
                    new CodePrimitiveExpression(entry.Expression.Trim()),
                    new CodeTypeOfExpression(entry.DeclaringType),
                    new CodePrimitiveExpression(entry.PropertyInfo.Name)));
     }
 }
        public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
        {
            string x = string.Empty;
            bool   y = true;

            if (expression != null)
            {
                if (expression.EndsWith(".connectionstring", StringComparison.OrdinalIgnoreCase))
                {
                    x = expression.Substring(0, expression.Length - ".connectionstring".Length);
                }
                else if (expression.EndsWith(".providername", StringComparison.OrdinalIgnoreCase))
                {
                    y = false;
                    x = expression.Substring(0, expression.Length - ".providername".Length);
                }
                else
                {
                    x = expression;
                }
            }
            return(new Pair(x, y));
        }
示例#42
0
        public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
        {
            ResourceExpressionFields fields = null;

            try
            {
                fields = ParseExpressionInternal(expression);
            }
            catch
            {
            }
            if (fields == null)
            {
                throw new HttpException(System.Web.SR.GetString("Invalid_res_expr", new object[] { expression }));
            }
            if (context.VirtualPathObject != null)
            {
                IResourceProvider resourceProvider = GetResourceProvider(fields, VirtualPath.Create(context.VirtualPath));
                object            obj2             = null;
                if (resourceProvider != null)
                {
                    try
                    {
                        obj2 = resourceProvider.GetObject(fields.ResourceKey, CultureInfo.InvariantCulture);
                    }
                    catch
                    {
                    }
                }
                if (obj2 == null)
                {
                    throw new HttpException(System.Web.SR.GetString("Res_not_found", new object[] { fields.ResourceKey }));
                }
            }
            return(fields);
        }
        public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
        {
            bool   wantsProviderName = false;
            string connStringName    = String.Empty;

            if (!String.IsNullOrEmpty(expression))
            {
                int subidx = expression.Length;

                if (expression.EndsWith(".providername", StringComparison.InvariantCultureIgnoreCase))
                {
                    wantsProviderName = true;
                    subidx           -= 13;
                }
                else if (expression.EndsWith(".connectionstring", StringComparison.InvariantCultureIgnoreCase))
                {
                    subidx -= 17;
                }

                connStringName = expression.Substring(0, subidx);
            }

            return(new Pair(connStringName, wantsProviderName));
        }
示例#44
0
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            ResourceExpressionFields fields = parsedData as ResourceExpressionFields;

            CodeExpression[] expr;

            // TODO: check what MS runtime does in this situation
            if (entry == null)
            {
                return(null);
            }

            if (!String.IsNullOrEmpty(fields.ClassKey))
            {
                if (!(entry.PropertyInfo is PropertyInfo))
                {
                    return(null);                    // TODO: check what MS runtime does here
                }
                expr = new CodeExpression [] {
                    new CodePrimitiveExpression(fields.ClassKey),
                    new CodePrimitiveExpression(fields.ResourceKey)
                };
                CodeMethodInvokeExpression getgro = new CodeMethodInvokeExpression(new CodeThisReferenceExpression(), "GetGlobalResourceObject", expr);
                return(new CodeCastExpression(entry.PropertyInfo.PropertyType, getgro));
            }
            else
            {
                return(CreateGetLocalResourceObject(entry, fields.ResourceKey));
            }
        }
示例#45
0
        public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            ResourceExpressionFields fields = parsedData as ResourceExpressionFields;

            return(HttpContext.GetGlobalResourceObject(fields.ClassKey, fields.ResourceKey));
        }
示例#46
0
 public override object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
 {
     //FIXME: not sure what the propertyType should be used for
     return(ParseExpression(expression));
 }
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            if (entry == null)
            {
                throw new NullReferenceException(".NET emulation (entry == null)");
            }

            var ret = new CodeMethodInvokeExpression();

            ret.Method = new CodeMethodReferenceExpression(new CodeTypeReferenceExpression(typeof(RouteUrlExpressionBuilder)), "GetRouteUrl");

            CodeExpressionCollection parameters = ret.Parameters;

            parameters.Add(new CodeThisReferenceExpression());
            parameters.Add(new CodePrimitiveExpression(entry.Expression));

            return(ret);
        }
        // This method is used only from within pages that aren't compiled
        public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            if (entry == null)
            {
                throw new NullReferenceException(".NET emulation (entry == null)");
            }

            if (context == null)
            {
                throw new NullReferenceException(".NET emulation (context == null)");
            }

            return(GetRouteUrl(context.TemplateControl, entry.Expression));
        }
 public override System.CodeDom.CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, Object parsedData, ExpressionBuilderContext context)
 {
     return(default(System.CodeDom.CodeExpression));
 }
示例#50
0
 public abstract System.CodeDom.CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, Object parsedData, ExpressionBuilderContext context);
示例#51
0
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            ResourceExpressionFields fields = (ResourceExpressionFields)parsedData;

            if (fields.ClassKey.Length == 0)
            {
                return(this.GetPageResCodeExpression(fields.ResourceKey, entry));
            }
            return(this.GetAppResCodeExpression(fields.ClassKey, fields.ResourceKey, entry));
        }
示例#52
0
 public override object EvaluateExpression(object target, System.Web.UI.BoundPropertyEntry entry, object parsedData, System.Web.Compilation.ExpressionBuilderContext context)
 {
     return(GetEvalData(entry.Expression));
 }
示例#53
0
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     return(GetRouteUrl(context.TemplateControl, entry.Expression.Trim()));
 }
示例#54
0
 public override System.CodeDom.CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, System.Web.Compilation.ExpressionBuilderContext context)
 {
     CodeExpression[] expressionArray = new CodeExpression[0];
     expressionArray[0] = new CodePrimitiveExpression(entry.Expression.Trim());
     return(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(base.GetType()), "GetEvalData", expressionArray));
 }
示例#55
0
        public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            Type type = entry.DeclaringType;
            PropertyDescriptor descriptor = TypeDescriptor.GetProperties(type)[entry.PropertyInfo.Name];

            CodeExpression[] expressionArray = new CodeExpression[3];
            expressionArray[0] = new CodePrimitiveExpression(entry.Expression.Trim());
            expressionArray[1] = new CodeTypeOfExpression(entry.Type);
            expressionArray[2] = new CodePrimitiveExpression(entry.Name);
            return(new CodeCastExpression(descriptor.PropertyType, new CodeMethodInvokeExpression(new
                                                                                                  CodeTypeReferenceExpression(base.GetType()), "GetAppSetting", expressionArray)));
        }
示例#56
0
 public virtual new Object ParseExpression(string expression, Type propertyType, ExpressionBuilderContext context)
 {
     return(default(Object));
 }
示例#57
0
 public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     return(GetAppSetting(entry.Expression.Trim()));
 }
 public override Object EvaluateExpression(Object target, System.Web.UI.BoundPropertyEntry entry, Object parsedData, ExpressionBuilderContext context)
 {
     return(default(Object));
 }
示例#59
0
        public override object EvaluateExpression(object target, BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
        {
            ResourceExpressionFields fields           = (ResourceExpressionFields)parsedData;
            IResourceProvider        resourceProvider = GetResourceProvider(fields, context.VirtualPathObject);

            if (entry.Type == typeof(string))
            {
                return(GetResourceObject(resourceProvider, fields.ResourceKey, null));
            }
            return(GetResourceObject(resourceProvider, fields.ResourceKey, null, entry.DeclaringType, entry.PropertyInfo.Name));
        }
示例#60
0
 public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
 {
     return(null);
 }