Ejemplo n.º 1
0
        internal static object[] CreateParameters(MethodInfo method, TemplateParserContext context)
        {
            ParameterInfo[] parameters = method.GetParameters();

            object[] parameterValues = new object[parameters.Length];

            int i = 0;
            foreach (ParameterInfo parameter in parameters)
            {
                ClientDataAttribute[] attributes = (ClientDataAttribute[])parameter.GetCustomAttributes(typeof(ClientDataAttribute), true);

                ClientDataAttribute mapAttribute;

                if (attributes.Length > 0)
                    mapAttribute = attributes[0];
                else
                    mapAttribute = new GetOrPostAttribute(parameter.Name);

                object value;
                Type type;

                if (context != null && context.Get(parameter.Name, out value, out type))
                    parameterValues[i++] = value.Convert(parameter.ParameterType);
                else
                    parameterValues[i++] = GetClientValue(mapAttribute, parameter.ParameterType); //TODO: add IObjectBinder support for complex objects
            }

            return parameterValues;
        }
Ejemplo n.º 2
0
        internal static object[] CreateParameters(MethodInfo method, TemplateParserContext context)
        {
            ParameterInfo[] parameters = method.GetParameters();

            object[] parameterValues = new object[parameters.Length];

            int i = 0;

            foreach (ParameterInfo parameter in parameters)
            {
                ClientDataAttribute[] attributes = (ClientDataAttribute[])parameter.GetCustomAttributes(typeof(ClientDataAttribute), true);

                ClientDataAttribute mapAttribute;

                if (attributes.Length > 0)
                {
                    mapAttribute = attributes[0];
                }
                else
                {
                    mapAttribute = new GetOrPostAttribute(parameter.Name);
                }

                object value;
                Type   type;

                if (context != null && context.Get(parameter.Name, out value, out type))
                {
                    parameterValues[i++] = value.Convert(parameter.ParameterType);
                }
                else
                {
                    parameterValues[i++] = GetClientValue(mapAttribute, parameter.ParameterType);
                }
            }

            return(parameterValues);
        }