NServiceBus.CallbackResponseHelper.ConvertFromReturnCode C# (CSharp) Method

ConvertFromReturnCode() public static method

public static ConvertFromReturnCode ( this returnCode, Type destinationType ) : object
returnCode this
destinationType System.Type
return object
        public static object ConvertFromReturnCode(this string returnCode, Type destinationType)
        {
            if (destinationType == typeof(int))
            {
                return Convert.ToInt32(returnCode);
            }

            if (destinationType == typeof(short))
            {
                return Convert.ToInt16(returnCode);
            }

            if (destinationType == typeof(long))
            {
                return Convert.ToInt64(returnCode);
            }

            if (destinationType.IsEnum())
            {
                return Enum.Parse(destinationType, returnCode);
            }

            throw new ArgumentException("The return code can only be an enum or an integer.", nameof(destinationType));
        }
    }