Пример #1
0
        private static MethodCallDescriptor EvaluateCorrectness(ParameterInfo[] mp, List <Type> paramTypes)
        {
            var result = new MethodCallDescriptor();

            if (mp.Length < paramTypes.Count)
            {
                return(null);
            }
            int i;

            for (i = 0; i < paramTypes.Count; i++)
            {
                var methodType = mp[i].ParameterType;
                var paramType  = paramTypes[i];
                if (!paramType.IsSubclassOf(methodType) && paramType != methodType)
                {
                    return(null);
                }
                result.ParamTypes.Add(methodType);
                result.ParamValues.Add(null);
                result.GoodFrom = i + 1;
            }
            if (mp.Length != paramTypes.Count)
            {
                for (int j = result.GoodFrom; j < mp.Length; j++)
                {
                    var methodParameter = mp[j];
                    if (!methodParameter.IsOptional)
                    {
                        return(null);
                    }
                    result.ParamTypes.Add(methodParameter.ParameterType);
                    result.ParamValues.Add(methodParameter.DefaultValue);
                }
            }
            return(result);
        }
Пример #2
0
		private static MethodCallDescriptor EvaluateCorrectness(ParameterInfo[] mp, List<Type> paramTypes)
		{
			var result = new MethodCallDescriptor();
			if (mp.Length < paramTypes.Count) return null;
			int i;
			for (i = 0; i < paramTypes.Count; i++)
			{
				var methodType = mp[i].ParameterType;
				var paramType = paramTypes[i];
				if (!paramType.IsSubclassOf(methodType) && paramType != methodType)
				{
					return null;
				}
				result.ParamTypes.Add(methodType);
				result.ParamValues.Add(null);
				result.GoodFrom = i + 1;
			}
			if (mp.Length != paramTypes.Count)
			{
				for (int j = result.GoodFrom; j < mp.Length; j++)
				{
					var methodParameter = mp[j];
					if (!methodParameter.IsOptional) return null;
					result.ParamTypes.Add(methodParameter.ParameterType);
					result.ParamValues.Add(methodParameter.DefaultValue);
				}
			}
			return result;
		}