public static TypeCode GetTypeCode(XTypeReference type) { if (type == null) return TypeCode.Empty; switch (type.Kind) { case XTypeReferenceKind.Bool: return TypeCode.Boolean; case XTypeReferenceKind.Char: return TypeCode.Char; case XTypeReferenceKind.SByte: return TypeCode.SByte; case XTypeReferenceKind.Byte: return TypeCode.Byte; case XTypeReferenceKind.Short: return TypeCode.Int16; case XTypeReferenceKind.UShort: return TypeCode.UInt16; case XTypeReferenceKind.Int: return TypeCode.Int32; case XTypeReferenceKind.UInt: return TypeCode.UInt32; case XTypeReferenceKind.Long: return TypeCode.Int64; case XTypeReferenceKind.ULong: return TypeCode.UInt64; case XTypeReferenceKind.Float: return TypeCode.Single; case XTypeReferenceKind.Double: return TypeCode.Double; default: if (type.IsSystemString()) return TypeCode.String; return TypeCode.Object; } }