public static FieldType getTypeCode(System.Type c)
{
FieldType type;
if (c.Equals(typeof(byte)))
{
type = FieldType.tpByte;
}
else if (c.Equals(typeof(sbyte)))
{
type = FieldType.tpSByte;
}
else if (c.Equals(typeof(short)))
{
type = FieldType.tpShort;
}
else if (c.Equals(typeof(ushort)))
{
type = FieldType.tpUShort;
}
else if (c.Equals(typeof(char)))
{
type = FieldType.tpChar;
}
else if (c.Equals(typeof(int)))
{
type = FieldType.tpInt;
}
else if (c.Equals(typeof(uint)))
{
type = FieldType.tpUInt;
}
else if (c.Equals(typeof(long)))
{
type = FieldType.tpLong;
}
else if (c.Equals(typeof(ulong)))
{
type = FieldType.tpULong;
}
else if (c.Equals(typeof(float)))
{
type = FieldType.tpFloat;
}
else if (c.Equals(typeof(double)))
{
type = FieldType.tpDouble;
}
else if (c.Equals(typeof(System.String)))
{
type = FieldType.tpString;
}
else if (c.Equals(typeof(bool)))
{
type = FieldType.tpBoolean;
}
else if (c.Equals(typeof(System.DateTime)))
{
type = FieldType.tpDate;
}
else if (c.IsEnum)
{
type = FieldType.tpEnum;
}
else if (c.Equals(typeof(decimal)))
{
type = FieldType.tpDecimal;
}
else if (c.Equals(typeof(Guid)))
{
type = FieldType.tpGuid;
}
else if (typeof(IPersistent).IsAssignableFrom(c))
{
type = FieldType.tpObject;
}
else if (typeof(ValueType).IsAssignableFrom(c))
{
type = FieldType.tpValue;
}
else if (typeof(IGenericPArray).IsAssignableFrom(c))
{
type = FieldType.tpArrayOfOid;
}
else if (typeof(IGenericLink).IsAssignableFrom(c))
{
type = FieldType.tpLink;
}
else if (c.IsArray)
{
type = getTypeCode(c.GetElementType());
if ((int)type >= (int)FieldType.tpLink)
{
throw new DatabaseException(DatabaseException.ErrorCode.UNSUPPORTED_TYPE, c);
}
type = (FieldType)((int)type + (int)FieldType.tpArrayOfBoolean);
}
else
{
type = FieldType.tpRaw;
}
return type;
}