Exemplo n.º 1
0
 /// <include file='doc\ValueCollectionParameterReader.uex' path='docs/doc[@for="ValueCollectionParameterReader.Read"]/*' />
 /// <devdoc>
 ///    <para>[To be supplied.]</para>
 /// </devdoc>
 protected object[] Read(NameValueCollection collection)
 {
     object[] parameters = new object[paramInfos.Length];
     for (int i = 0; i < paramInfos.Length; i++)
     {
         ParameterInfo paramInfo = paramInfos[i];
         if (paramInfo.ParameterType.IsArray)
         {
             string[] arrayValues = collection.GetValues(paramInfo.Name);
             Type     arrayType   = paramInfo.ParameterType.GetElementType();
             Array    array       = Array.CreateInstance(arrayType, arrayValues.Length);
             for (int j = 0; j < arrayValues.Length; j++)
             {
                 string value = arrayValues[j];
                 array.SetValue(ScalarFormatter.FromString(value, arrayType), j);
             }
             parameters[i] = array;
         }
         else
         {
             string value = collection[paramInfo.Name];
             if (value == null)
             {
                 throw new InvalidOperationException(Res.GetString(Res.WebMissingParameter, paramInfo.Name));
             }
             parameters[i] = ScalarFormatter.FromString(value, paramInfo.ParameterType);
         }
     }
     return(parameters);
 }
Exemplo n.º 2
0
 internal static bool AreUrlParametersSupported(LogicalMethodInfo methodInfo)
 {
     if (methodInfo.OutParameters.Length > 0)
     {
         return(false);
     }
     ParameterInfo[] parameters = methodInfo.InParameters;
     for (int i = 0; i < parameters.Length; i++)
     {
         ParameterInfo parameter     = parameters[i];
         Type          parameterType = parameter.ParameterType;
         if (parameterType.IsArray)
         {
             if (!ScalarFormatter.IsTypeSupported(parameterType.GetElementType()))
             {
                 return(false);
             }
         }
         else
         {
             if (!ScalarFormatter.IsTypeSupported(parameterType))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
 protected object[] Read(NameValueCollection collection)
 {
     object[] objArray = new object[this.paramInfos.Length];
     for (int i = 0; i < this.paramInfos.Length; i++)
     {
         ParameterInfo info = this.paramInfos[i];
         if (info.ParameterType.IsArray)
         {
             string[] values      = collection.GetValues(info.Name);
             Type     elementType = info.ParameterType.GetElementType();
             Array    array       = Array.CreateInstance(elementType, values.Length);
             for (int j = 0; j < values.Length; j++)
             {
                 string str = values[j];
                 array.SetValue(ScalarFormatter.FromString(str, elementType), j);
             }
             objArray[i] = array;
         }
         else
         {
             string str2 = collection[info.Name];
             if (str2 == null)
             {
                 throw new InvalidOperationException(Res.GetString("WebMissingParameter", new object[] { info.Name }));
             }
             objArray[i] = ScalarFormatter.FromString(str2, info.ParameterType);
         }
     }
     return(objArray);
 }
Exemplo n.º 4
0
        /// <include file='doc\ValueCollectionParameterReader.uex' path='docs/doc[@for="ValueCollectionParameterReader.IsSupported1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        static public bool IsSupported(ParameterInfo paramInfo)
        {
            Type type = paramInfo.ParameterType;

            if (type.IsArray)
            {
                type = type.GetElementType();
            }
            return(ScalarFormatter.IsTypeSupported(type));
        }
 protected void Encode(TextWriter writer, string name, object value)
 {
     if (this.numberEncoded > 0)
     {
         writer.Write('&');
     }
     writer.Write(this.UrlEncode(name));
     writer.Write('=');
     writer.Write(this.UrlEncode(ScalarFormatter.ToString(value)));
     this.numberEncoded++;
 }
 internal static bool AreUrlParametersSupported(LogicalMethodInfo methodInfo)
 {
     if (methodInfo.OutParameters.Length > 0)
     {
         return(false);
     }
     foreach (ParameterInfo info in methodInfo.InParameters)
     {
         Type parameterType = info.ParameterType;
         if (parameterType.IsArray)
         {
             if (!ScalarFormatter.IsTypeSupported(parameterType.GetElementType()))
             {
                 return(false);
             }
         }
         else if (!ScalarFormatter.IsTypeSupported(parameterType))
         {
             return(false);
         }
     }
     return(true);
 }