Beispiel #1
0
        public Method(MethodInfo method, Object target)
        {
            if (method == null)
                throw new ArgumentNullException("method");

            if (!method.IsStatic && target == null)
                throw new ArgumentNullException("target", "Target cannot be null when non-static method specified.");

            if (method.IsConstructor)
                throw new ArgumentException("Cannot use class constructor as method.", "method");

            this.method = method;
            this.target = target;

            ParameterInfo[] paramList = method.GetParameters();
            parameters = new InputParameter[paramList.Length];

            for (int i = 0; i < paramList.Length; i++)
            {
                parameters[i] = new InputParameter(paramList[i]);

                if (!parameters[i].IsOptional && !parameters[i].IsParamArray)
                    minParamCount++;

                maxParamCount++;
            }

            if (parameters.Length > 0 && parameters[parameters.Length - 1].IsParamArray)
                maxParamCount = Int32.MaxValue;
        }
Beispiel #2
0
        public Method(MethodInfo method, Object target)
        {
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            if (!method.IsStatic && target == null)
            {
                throw new ArgumentNullException("target", "Target cannot be null when non-static method specified.");
            }

            if (method.IsConstructor)
            {
                throw new ArgumentException("Cannot use class constructor as method.", "method");
            }

            this.method = method;
            this.target = target;

            ParameterInfo[] paramList = method.GetParameters();
            parameters = new InputParameter[paramList.Length];

            for (int i = 0; i < paramList.Length; i++)
            {
                parameters[i] = new InputParameter(paramList[i]);

                if (!parameters[i].IsOptional && !parameters[i].IsParamArray)
                {
                    minParamCount++;
                }

                maxParamCount++;
            }

            if (parameters.Length > 0 && parameters[parameters.Length - 1].IsParamArray)
            {
                maxParamCount = Int32.MaxValue;
            }
        }
Beispiel #3
0
 public object ConvertTo(InputParameter targetParam)
 {
     return(ConvertTo(targetParam.Type, targetParam.Class));
 }
Beispiel #4
0
 public object ConvertTo(InputParameter targetParam)
 {
     return ConvertTo(targetParam.Type, targetParam.Class);
 }