private List <ReflectedGenericParameterInfo> GetGenericParameters(Type[] parameters, bool isMethod)
        {
            var list = new List <ReflectedGenericParameterInfo>();

            foreach (var genericParameter in parameters)
            {
                var constraints   = genericParameter.GenericParameterAttributes;
                var parameterInfo = new ReflectedGenericParameterInfo {
                    Name                       = genericParameter.Name,
                    MethodParameter            = isMethod,
                    ParameterPosition          = genericParameter.GenericParameterPosition,
                    MustBeReferenceType        = GetConstraint(constraints, GenericParameterAttributes.ReferenceTypeConstraint),
                    MustBeValueType            = GetConstraint(constraints, GenericParameterAttributes.NotNullableValueTypeConstraint),
                    MustHaveDefaultConstructor = GetConstraint(constraints, GenericParameterAttributes.DefaultConstructorConstraint),
                };
                if (parameterInfo.MustBeValueType)
                {
                    parameterInfo.MustHaveDefaultConstructor = false;
                }
                list.Add(parameterInfo);
            }
            return(list);
        }
Beispiel #2
0
 private List<ReflectedGenericParameterInfo> GetGenericParameters(Type[] parameters, bool isMethod) {
     var list = new List<ReflectedGenericParameterInfo>();
     foreach(var genericParameter in parameters) {
         var constraints = genericParameter.GenericParameterAttributes;
         var parameterInfo = new ReflectedGenericParameterInfo {
             Name = genericParameter.Name,
             MethodParameter = isMethod,
             ParameterPosition = genericParameter.GenericParameterPosition,
             MustBeReferenceType = GetConstraint(constraints, GenericParameterAttributes.ReferenceTypeConstraint),
             MustBeValueType = GetConstraint(constraints, GenericParameterAttributes.NotNullableValueTypeConstraint),
             MustHaveDefaultConstructor = GetConstraint(constraints, GenericParameterAttributes.DefaultConstructorConstraint),
         };
         if(parameterInfo.MustBeValueType) {
             parameterInfo.MustHaveDefaultConstructor = false;
         }
         list.Add(parameterInfo);
     }
     return list;
 }