本文整理汇总了C#中Type.GetTypeCodeEx方法的典型用法代码示例。如果您正苦于以下问题:C# Type.GetTypeCodeEx方法的具体用法?C# Type.GetTypeCodeEx怎么用?C# Type.GetTypeCodeEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Type
的用法示例。
在下文中一共展示了Type.GetTypeCodeEx方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsConvertible
static bool IsConvertible(Type type)
{
if (type.IsEnumEx())
return false;
switch (type.GetTypeCodeEx())
{
case TypeCode.Boolean :
case TypeCode.Byte :
case TypeCode.SByte :
case TypeCode.Int16 :
case TypeCode.Int32 :
case TypeCode.Int64 :
case TypeCode.UInt16 :
case TypeCode.UInt32 :
case TypeCode.UInt64 :
case TypeCode.Single :
case TypeCode.Double :
case TypeCode.Decimal :
case TypeCode.Char : return true;
default : return false;
}
}
示例2: GetReaderMethodInfo
static MethodInfo GetReaderMethodInfo(Type type)
{
switch (type.GetTypeCodeEx())
{
case TypeCode.Boolean : return MemberHelper.MethodOf<IDataReader>(r => r.GetBoolean (0));
case TypeCode.Byte : return MemberHelper.MethodOf<IDataReader>(r => r.GetByte (0));
case TypeCode.Char : return MemberHelper.MethodOf<IDataReader>(r => r.GetChar (0));
case TypeCode.Int16 : return MemberHelper.MethodOf<IDataReader>(r => r.GetInt16 (0));
case TypeCode.Int32 : return MemberHelper.MethodOf<IDataReader>(r => r.GetInt32 (0));
case TypeCode.Int64 : return MemberHelper.MethodOf<IDataReader>(r => r.GetInt64 (0));
case TypeCode.Single : return MemberHelper.MethodOf<IDataReader>(r => r.GetFloat (0));
case TypeCode.Double : return MemberHelper.MethodOf<IDataReader>(r => r.GetDouble (0));
case TypeCode.String : return MemberHelper.MethodOf<IDataReader>(r => r.GetString (0));
case TypeCode.Decimal : return MemberHelper.MethodOf<IDataReader>(r => r.GetDecimal (0));
case TypeCode.DateTime : return MemberHelper.MethodOf<IDataReader>(r => r.GetDateTime(0));
}
if (type == typeof(Guid))
return MemberHelper.MethodOf<IDataReader>(r => r.GetGuid(0));
return MemberHelper.MethodOf<IDataReader>(dr => dr.GetValue(0));
}
示例3: SetConverter
public void SetConverter(Type type, ConverterType converter)
{
if (converter == null)
{
if (_converters.ContainsKey(type))
_converters.Remove(type);
}
else
{
_converters[type] = converter;
switch (type.GetTypeCodeEx())
{
case TypeCode.Boolean : _booleanConverter = converter; return;
case TypeCode.Char : _charConverter = converter; return;
case TypeCode.SByte : _sByteConverter = converter; return;
case TypeCode.Byte : _byteConverter = converter; return;
case TypeCode.Int16 : _int16Converter = converter; return;
case TypeCode.UInt16 : _uInt16Converter = converter; return;
case TypeCode.Int32 : _int32Converter = converter; return;
case TypeCode.UInt32 : _uInt32Converter = converter; return;
case TypeCode.Int64 : _int64Converter = converter; return;
case TypeCode.UInt64 : _uInt64Converter = converter; return;
case TypeCode.Single : _singleConverter = converter; return;
case TypeCode.Double : _doubleConverter = converter; return;
case TypeCode.Decimal : _decimalConverter = converter; return;
case TypeCode.DateTime : _dateTimeConverter = converter; return;
case TypeCode.String : _stringConverter = converter; return;
}
}
}