Esempio n. 1
0
        /// <summary>
        /// Add properties to the validator that will go to the Page_Validators array
        /// </summary>
        /// <param name="properties"></param>
        protected virtual void addValidatorDeclarationProperties(NameValueCollection properties)
        {
            if (controlToValidate != null)
            {
                properties.Add("controltovalidate", controlToValidate.ClientID);
            }

            properties.Add("evaluationfunction", evaluationFunction);
            properties.Add("errormessage", BuiltInFunction.EncodeHtml(Attributes["ErrorMessage"]));
        }
        private static string _getPropertyGetValue(string property, object key, object value)
        {
            if (value == null)
            {
                return("");
            }

            string           propertyName            = property + "[" + key + "]";
            AbstractCallback valueAsAbstractCallback = value as AbstractCallback;

            if (valueAsAbstractCallback != null)
            {
                return(_getPropertyText(propertyName, valueAsAbstractCallback));
            }

            Type valueAsType = value as Type;

            if (valueAsType != null)
            {
                return(_getPropertyText(propertyName, valueAsType));
            }

            IList valueAsIList = value as IList;

            if (valueAsIList != null)
            {
                return(_getPropertyText(propertyName, valueAsIList));
            }

            // See if value is a dictionary
            Type valueType = value.GetType();
            Type iGenericDictionaryType = typeof(IDictionary <,>);

            if (valueType.IsGenericType && iGenericDictionaryType.IsAssignableFrom(valueType.GetGenericTypeDefinition()))
            {
                MethodInfo getPropertyTextMethod = typeof(CallbackResultStorage).GetMethod("_getPropertyText",
                                                                                           BindingFlags.Static | BindingFlags.NonPublic, null,
                                                                                           new Type[] { typeof(string), iGenericDictionaryType.MakeGenericType(valueType.GetGenericArguments()) }, null);

                getPropertyTextMethod.Invoke(null, new object[] { propertyName, value });
            }

            return(BuiltInFunction.EncodeHtml(value.ToString()));
        }