Exemple #1
0
        /// <devdoc>
        /// </devdoc>
        private static object Eval(object container, string[] expressionParts)
        {
            Debug.Assert((expressionParts != null) && (expressionParts.Length != 0),
                         "invalid expressionParts parameter");

            object prop;
            int    i;

            for (prop = container, i = 0; (i < expressionParts.Length) && (prop != null); i++)
            {
                string expr        = expressionParts[i];
                bool   indexedExpr = expr.IndexOfAny(indexExprStartChars) >= 0;

                if (indexedExpr == false)
                {
                    prop = DataBinder.GetPropertyValue(prop, expr);
                }
                else
                {
                    prop = DataBinder.GetIndexedPropertyValue(prop, expr);
                }
            }

            return(prop);
        }
Exemple #2
0
        /// <devdoc>
        /// </devdoc>
        public static string GetIndexedPropertyValue(object container, string propName, string format)
        {
            object value = DataBinder.GetIndexedPropertyValue(container, propName);

            if ((value == null) || (value == System.DBNull.Value))
            {
                return(String.Empty);
            }
            else
            {
                if (String.IsNullOrEmpty(format))
                {
                    return(value.ToString());
                }
                else
                {
                    return(string.Format(format, value));
                }
            }
        }