context: using System;
  using System.Data.Odbc;
  using System.Data.OleDb;
  using USC.GISResearchLab.Common.Core.Databases;
  using USC.GISResearchLab.Common.Databases.TypeConverters;
  using USC.GISResearchLab.Common.Databases.TypeConverters.DatabaseTypeConverters;
  
  namespace USC.GISResearchLab.Common.Databases.Access
  {
      public class AccessTypeConverter : AbstractDatabaseTypeConverterManager
      {
  
          #region TypeNames
  
          public static string TYPENAME_Binary = "Binary";
          public static string TYPENAME_Bit = "Bit";
          public static string TYPENAME_Counter = "Counter";
          public static string TYPENAME_Currency = "Currency";
          public static string TYPENAME_DateTime = "DateTime";
          public static string TYPENAME_Decimal = "Decimal";
          public static string TYPENAME_Double = "Double";
          public static string TYPENAME_Guid = "Guid";
          public static string TYPENAME_Long = "Long";
          public static string TYPENAME_LongBinary = "LongBinary";
          public static string TYPENAME_LongText = "LongText";
          public static string TYPENAME_Numeric = "Numeric";
          public static string TYPENAME_Single = "Single";
          public static string TYPENAME_Short = "Short";
          public static string TYPENAME_UByte = "Unsigned Byte";
          public static string TYPENAME_VarChar = "VarChar";
          public static string TYPENAME_VarBinary = "VarBinary";
          #endregion
  
          public AccessTypeConverter()
          {
              DatabaseType = DatabaseType.Access;
          }
  
  
          public override int GetDefaultLength(DatabaseSuperDataType type)
          {
              int ret = -1;
  
              switch (type)
              {
  
                  case DatabaseSuperDataType.Decimal:
                  case DatabaseSuperDataType.Double:
                  case DatabaseSuperDataType.Float:
                      ret = 28;
                      break;
                  case DatabaseSuperDataType.VarChar:
                      ret = 255;
                      break;
                  default:
                      break;
              }
              return ret;
          }
  
  
          public override int GetDefaultPrecision(DatabaseSuperDataType type)
          {
              int ret = -1;
  
              switch (type)
              {
                  case DatabaseSuperDataType.Decimal:
                  case DatabaseSuperDataType.Double:
                  case DatabaseSuperDataType.Float:
                      ret = 18;
                      break;
                  default:
                      break;
              }
              return ret;
          }
  
          public override object ConvertType(object dbType, DatabaseType databaseType)
          {
              throw new NotImplementedException();
          }
  
          public DatabaseSuperDataType ToSuperType(object dbType)
          {
              DatabaseSuperDataType ret = DatabaseSuperDataType.VarChar;
              if (dbType.GetType() == typeof(OleDbType))
              {
                  ret = ToSuperType((OleDbType)dbType);
              }
              else if (dbType.GetType() == typeof(OdbcType))
              {
                  ret = ToSuperType((OdbcType)dbType);
              }
              return ret;
          }
  
          public DatabaseSuperDataType ToSuperType(OleDbType type)
          {
              DatabaseSuperDataType ret;
  
              switch (type)
              {
                  case OleDbType.BigInt:
                      ret = DatabaseSuperDataType.Long;
                      break;
                  case OleDbType.Binary:
                      ret = DatabaseSuperDataType.Binary;
                      break;
                  case OleDbType.Boolean:
                      ret = DatabaseSuperDataType.Bit;
                      break;
                  case OleDbType.BSTR:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Char:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Currency:
                      ret = DatabaseSuperDataType.Currency;
                      break;
                  case OleDbType.Date:
                      ret = DatabaseSuperDataType.DateTime;
                      break;
                  case OleDbType.DBDate:
                      ret = DatabaseSuperDataType.DateTime;
                      break;
                  case OleDbType.DBTime:
                      ret = DatabaseSuperDataType.DateTime;
                      break;
                  case OleDbType.DBTimeStamp:
                      ret = DatabaseSuperDataType.DateTime;
                      break;
                  case OleDbType.Decimal:
                      ret = DatabaseSuperDataType.Numeric;
                      break;
                  case OleDbType.Double:
                      ret = DatabaseSuperDataType.Double;
                      break;
                  case OleDbType.Empty:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Error:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Filetime:
                      ret = DatabaseSuperDataType.DateTime;
                      break;
                  case OleDbType.Guid:
                      ret = DatabaseSuperDataType.Guid;
                      break;
                  case OleDbType.IDispatch:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Integer:
                      ret = DatabaseSuperDataType.Numeric;
                      break;
                  case OleDbType.IUnknown:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.LongVarBinary:
                      ret = DatabaseSuperDataType.VarBinary;
                      break;
                  case OleDbType.LongVarChar:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.LongVarWChar:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Numeric:
                      ret = DatabaseSuperDataType.Numeric;
                      break;
                  case OleDbType.PropVariant:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Single:
                      ret = DatabaseSuperDataType.Single;
                      break;
                  case OleDbType.SmallInt:
                      ret = DatabaseSuperDataType.Short;
                      break;
                  case OleDbType.TinyInt:
                      ret = DatabaseSuperDataType.Short;
                      break;
                  case OleDbType.UnsignedBigInt:
                      ret = DatabaseSuperDataType.UByte;
                      break;
                  case OleDbType.UnsignedInt:
                      ret = DatabaseSuperDataType.UByte;
                      break;
                  case OleDbType.UnsignedSmallInt:
                      ret = DatabaseSuperDataType.UByte;
                      break;
                  case OleDbType.UnsignedTinyInt:
                      ret = DatabaseSuperDataType.UByte;
                      break;
                  case OleDbType.VarBinary:
                      ret = DatabaseSuperDataType.VarBinary;
                      break;
                  case OleDbType.VarChar:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.Variant:
                      ret = DatabaseSuperDataType.VarChar;
                      break;
                  case OleDbType.VarNumeric:
                      ret = DatabaseSuperDataType.Numeric;
                      break;
                  case OleDbType.VarWChar:
                      ret = DatabaseSuperDataType.UByte;
                      break;
                  case OleDbType.WChar:
                      ret = DatabaseSuperDataType.UByte;
                      break;
                  default:
  
gt:                     throw new Exception("Unexpected type: " + type);