- public readonly Type Type;
- public readonly Type UnderlyingType;
- public readonly MethodInfo HasValue;
- public readonly MethodInfo Value;
- public readonly MethodInfo GetValueOrDefault;
- public readonly ConstructorInfo Constructor;
-
- public NullableInfo (Type type)
- {
- Type = type;
- UnderlyingType = TypeManager.GetTypeArguments (type) [0];
-
- PropertyInfo has_value_pi = TypeManager.GetPredefinedProperty (type, "HasValue", Location.Null);
- PropertyInfo value_pi = TypeManager.GetPredefinedProperty (type, "Value", Location.Null);
- GetValueOrDefault = TypeManager.GetPredefinedMethod (type, "GetValueOrDefault", Location.Null, Type.EmptyTypes);
-
- HasValue = has_value_pi.GetGetMethod (false);
- Value = value_pi.GetGetMethod (false);
-#if MS_COMPATIBLE
- if (UnderlyingType.Module == CodeGen.Module.Builder) {
- Type o_type = TypeManager.DropGenericTypeArguments (type);
- Constructor = TypeBuilder.GetConstructor (type,
- TypeManager.GetPredefinedConstructor (o_type, Location.Null, o_type.GetGenericArguments ()));
- return;
- }
-#endif
- Constructor = type.GetConstructor (new Type[] { UnderlyingType });
+ public static MethodSpec GetConstructor (TypeSpec nullableType)
+ {
+ return TypeManager.GetPredefinedConstructor (nullableType, Location.Null, GetUnderlyingType (nullableType));