Ejemplo n.º 1
0
    public static ConstructorInfo GetConstructorInfo(Type type, params Type[] argsType)
    {
        IEnumerable <ConstructorInfo> constructors = ReflectionsUtils.GetConstructors(type);
        ConstructorInfo result;

        foreach (ConstructorInfo current in constructors)
        {
            ParameterInfo[] parameters = current.GetParameters();
            if (argsType.Length == parameters.Length)
            {
                int             num         = 0;
                bool            flag        = true;
                ParameterInfo[] parameters2 = current.GetParameters();
                for (int i = 0; i < parameters2.Length; i++)
                {
                    ParameterInfo parameterInfo = parameters2[i];
                    if (parameterInfo.ParameterType != argsType[num])
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    result = current;
                    return(result);
                }
            }
        }
        result = null;
        return(result);
    }