using System;
using System.Collections.Generic;
using System.Text;
/*
* Copyright Jeff Gaines 2007 - 2011 (jeff@jgaines.co.uk)
* Free licence for private use
* Please contact the author if you wish to use the code commercially
*/
namespace JGCreateDataClasses
{
/// <summary>
/// Maps ADO data types between C# (NET), XML and Access and indicates if it is a numeric field
/// </summary>
class JADODataTypes
{
public int ADOValue;
public string ADOConstant;
public string AccessType;
public string NETType;
public string XMLType;
public bool IsNumeric;
// These are in order ADOValue, ADOConstant, AccessType, NETType, XMLType, IsNumeric
internal enum ADOTypesIndex
{
ADOValue,
ADOConstant,
AccessType,
NETType,
XMLType,
IsNumeric
}
internal JADODataTypes(ADOTypesIndex typeIndex, string keyName)
{
int index = GetArrayIndexFromKey(typeIndex, keyName);
this.ADOValue = Convert.ToInt32(ADOTypesArray[index, (int)ADOTypesIndex.ADOValue]);
this.ADOConstant = ADOTypesArray[index, (int)ADOTypesIndex.ADOConstant];
this.AccessType = ADOTypesArray[index, (int)ADOTypesIndex.AccessType];
this.NETType = ADOTypesArray[index, (int)ADOTypesIndex.NETType];
this.XMLType = ADOTypesArray[index, (int)ADOTypesIndex.XMLType];
this.IsNumeric = (ADOTypesArray[index, (int)ADOTypesIndex.IsNumeric] == "1");
}
private int GetArrayIndexFromKey(ADOTypesIndex typeIndex, string keyName)
{
int result = -1;
for (int count = 0; count <= ADOTypesArray.GetUpperBound(0); count++)
{
if (ADOTypesArray[count, (int)typeIndex] == keyName)
{
result = count;
break;
}
}
return result;
}
// These are in order ADOValue, ADOConstant, AccessType, NETType, XMLType, IsNumeric
private static string[,] ADOTypesArray =
{
{"0","adEmpty","","Empty","","0"},
{"2","adSmallInt","Integer","Int16","System.Int16","1"},
{"3","adInteger","Integer","Int32","System.Int32","1"},
{"4","adSingle","Single","Single","System.Single","1"},
{"5","adDouble","Double","double","System.Double","1"},
{"6","adCurrency","Currency","decimal","System.Decimal","1"},
{"7","adDate","DateTime","DateTime","System.DateTime","0"},
{"8","adBSTR","Text","string","System.String","0"},
{"9","adIDispatch","","object","","0"},
{"10","adError","","External-Exception","","0"},
{"11","adBoolean","YesNo","bool","System.Boolean","0"},
{"12","adVariant","","object","","0"},
{"13","adIUnknown","","object","","0"},
{"14","adDecimal","","Decimal","System.Decimal","1"},
{"16","adTinyInt","Integer","byte","System.Byte","1"},
{"17","adUnsignedTinyInt","Integer","byte","System.UInt16","1"},
{"18","adUnsignedSmallInt","Integer","UInt16","System.UInt16","1"},
{"19","adUnsignedInt","Integer","UInt32","System.UInt32","1"},
{"20","adBigInt","LongInteger","Int64","System.Int64","1"},
{"21","adUnsignedBigInt","","","System.UInt64","1"},
{"64","adFileTime","","","System.UInt64","1"},
{"72","adGUID","","","","0"},
{"128","adBinary","LongInteger","byte[]","System.Byte[]","0"},
{"129","adChar","Text","string","System.Char","0"},
{"130","adWChar","Text","string","System.Char","0"},
{"131","adNumeric","Decimal","Decimal","System.Decimal","1"},
{"132","adUserDefined","","","","0"},
{"133","adDBDate","DateTime","DateTime","System.DateTime","0"},
{"134","adDBTime","DateTime","DateTime","System.DateTime","0"},
{"135","adDBTimeStamp","DateTime","DateTime","System.DateTime","0"},
{"136","adChapter","","","","0"},
{"138","adPropVariant","","","","0"},
{"139","adVarNumeric","","OleDbType.VarNumeric","","0"},
{"200","adVarChar","Text","string","System.String","0"},
{"201","adLongVarChar","Memo","string","System.String","0"},
{"202","adVarWChar","Text","string","System.String","0"},
{"203","adLongVarWChar","Memo","string","System.String","0"},
{"204","adVarBinary","ReplicationID","byte[]","","0"},
{"205","adLongVarBinary","OLEObject","byte[]","","0"},
{"8192","AdArray","","","",""}
};
}
}