Esempio n. 1
0
        private string GetField(Parameter parameter)
        {
            var defaultPropertyAttribute = Attribute.GetCustomAttributes(parameter.GetType()).First(a => a is DefaultPropertyAttribute) as DefaultPropertyAttribute;
            string field = null;
            if (defaultPropertyAttribute != null && defaultPropertyAttribute.Name != "DefaultValue")
            {
                field = parameter.GetType().GetProperty(defaultPropertyAttribute.Name).GetValue(parameter, null) as string;
            }

            return field ?? parameter.Name;
        }
 internal static string GetParameterExpression(IServiceProvider serviceProvider, Parameter p, System.Web.UI.Control control, out bool isHelperText)
 {
     if (p.GetType() == typeof(ControlParameter))
     {
         ControlParameter parameter = (ControlParameter) p;
         if (parameter.ControlID.Length == 0)
         {
             isHelperText = true;
             return System.Design.SR.GetString("ParameterEditorUserControl_ControlParameterExpressionUnknown");
         }
         string propertyName = parameter.PropertyName;
         if (propertyName.Length == 0)
         {
             propertyName = GetControlDefaultValuePropertyName(parameter.ControlID, serviceProvider, control);
         }
         if (propertyName.Length > 0)
         {
             isHelperText = false;
             return (parameter.ControlID + "." + propertyName);
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_ControlParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(FormParameter))
     {
         FormParameter parameter2 = (FormParameter) p;
         if (parameter2.FormField.Length > 0)
         {
             isHelperText = false;
             return string.Format(CultureInfo.InvariantCulture, "Request.Form(\"{0}\")", new object[] { parameter2.FormField });
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_FormParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(QueryStringParameter))
     {
         QueryStringParameter parameter3 = (QueryStringParameter) p;
         if (parameter3.QueryStringField.Length > 0)
         {
             isHelperText = false;
             return string.Format(CultureInfo.InvariantCulture, "Request.QueryString(\"{0}\")", new object[] { parameter3.QueryStringField });
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_QueryStringParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(RouteParameter))
     {
         RouteParameter parameter4 = (RouteParameter) p;
         if (parameter4.RouteKey.Length > 0)
         {
             isHelperText = false;
             return string.Format(CultureInfo.InvariantCulture, "Page.RouteData(\"{0}\")", new object[] { parameter4.RouteKey });
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_RouteParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(CookieParameter))
     {
         CookieParameter parameter5 = (CookieParameter) p;
         if (parameter5.CookieName.Length > 0)
         {
             isHelperText = false;
             return string.Format(CultureInfo.InvariantCulture, "Request.Cookies(\"{0}\").Value", new object[] { parameter5.CookieName });
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_CookieParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(SessionParameter))
     {
         SessionParameter parameter6 = (SessionParameter) p;
         if (parameter6.SessionField.Length > 0)
         {
             isHelperText = false;
             return string.Format(CultureInfo.InvariantCulture, "Session(\"{0}\")", new object[] { parameter6.SessionField });
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_SessionParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(ProfileParameter))
     {
         ProfileParameter parameter7 = (ProfileParameter) p;
         if (parameter7.PropertyName.Length > 0)
         {
             isHelperText = false;
             return string.Format(CultureInfo.InvariantCulture, "Profile(\"{0}\")", new object[] { parameter7.PropertyName });
         }
         isHelperText = true;
         return System.Design.SR.GetString("ParameterEditorUserControl_ProfileParameterExpressionUnknown");
     }
     if (p.GetType() == typeof(Parameter))
     {
         Parameter parameter8 = p;
         if (parameter8.DefaultValue == null)
         {
             isHelperText = false;
             return string.Empty;
         }
         isHelperText = false;
         return parameter8.DefaultValue;
     }
     isHelperText = true;
     return p.GetType().Name;
 }