private static RppGenericParameter CreateGenericParameter(string name, int genericArgumentPosition, RType declaringType, RppMethodInfo declaringMethod) { RppGenericParameter genericParameter = new RppGenericParameter(name); RType type = new RType(name, RTypeAttributes.None, null, declaringType) { IsGenericParameter = true, GenericParameterPosition = genericArgumentPosition, GenericParameterDeclaringMethod = declaringMethod }; genericParameter.Type = type; genericParameter.Position = genericArgumentPosition; return genericParameter; }
private static GenericParameterAttributes GetAttributes(RppGenericParameter parameter) { switch (parameter.Variance) { case RppGenericParameterVariance.Covariant: return GenericParameterAttributes.Covariant; case RppGenericParameterVariance.Contravariant: return GenericParameterAttributes.Contravariant; default: return GenericParameterAttributes.None; } }
private static void UpdateGenericParameterContraints(RppGenericParameter genericParameter, GenericTypeParameterBuilder nativeGenericParameter) { if (genericParameter.Constraint != null) { if (genericParameter.Constraint.IsClass) { nativeGenericParameter.SetBaseTypeConstraint(genericParameter.Constraint.NativeType); } else { nativeGenericParameter.SetInterfaceConstraints(genericParameter.Constraint.NativeType); } } }
private static void UpdateGenericParameter(RppGenericParameter genericParameter, GenericTypeParameterBuilder nativeGenericParameter) { genericParameter.SetGenericTypeParameterBuilder(nativeGenericParameter); UpdateGenericParameterContraints(genericParameter, nativeGenericParameter); }