Thinktecture.Tools.Web.Services.CodeGeneration.CodeDomExtensions.CloseNullableType C# (CSharp) Method

CloseNullableType() public static method

Creates a closed generic nullable type from the current CodeTypeReference.
Thrown if the code type reference does not represent a nullable type.
public static CloseNullableType ( this reference ) : Type
reference this The code type reference.
return System.Type
        public static Type CloseNullableType(this CodeTypeReference reference)
        {
            if (!reference.IsNullableType())
            {
                throw new InvalidOperationException("The current code type reference is not a nullable type.");
            }
            Type valueType = Type.GetType(reference.TypeArguments[0].BaseType);
            return typeof(Nullable<>).MakeGenericType(valueType);
        }