ColumnType.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace OTSModelSharp.DTLBase
  7. {
  8. public class ColumnType
  9. {
  10. public enum ID
  11. {
  12. MIN = 0,
  13. INTEGER = 0,
  14. FLOAT = 1,
  15. STRING = 2,
  16. BLOB = 3,
  17. NONE = 4,
  18. MAX = 4
  19. };
  20. public ColumnType( ID a_nTypeId,
  21. bool a_bIsNotNull = false,
  22. bool a_bIsUnique = false)
  23. {
  24. m_nTypeId = a_nTypeId;
  25. m_bIsNotNull = a_bIsNotNull;
  26. m_bIsUnique = a_bIsUnique;
  27. }
  28. ~ColumnType()
  29. { }
  30. public ID GetTypeId() { return m_nTypeId; }
  31. public bool IsIsNotNull() { return m_bIsNotNull; }
  32. public bool IsIsUnique() { return m_bIsUnique; }
  33. public string GetName()
  34. {
  35. return GetTypeId().ToString();
  36. }
  37. public string GetFormat(int position)
  38. {
  39. int nId =(int) GetTypeId();
  40. string sRet;
  41. switch (nId)
  42. {
  43. case (int)ColumnType.ID.INTEGER:
  44. sRet = "{"+position.ToString()+":G}";
  45. break;
  46. case (int)ColumnType.ID.FLOAT:
  47. sRet = "{" + position.ToString() + ":G}";
  48. break;
  49. case (int)ColumnType.ID.STRING:
  50. sRet = "\"{" + position.ToString() + ":G}\"";
  51. break;
  52. case (int)ColumnType.ID.BLOB:
  53. sRet = "@blob";
  54. break;
  55. case (int)ColumnType.ID.NONE:
  56. sRet = "\"{" + position.ToString() + ":G}\"";
  57. break;
  58. default:
  59. sRet = "\"{" + position.ToString() + ":G}\"";
  60. break;
  61. }
  62. return sRet;
  63. }
  64. static string PrimaryKeyString() { return m_sPrimaryKeyString; }
  65. static string NotNullString() { return m_sNotNullString; }
  66. static string UniqueString() { return m_sUniqueString; }
  67. ID m_nTypeId;
  68. bool m_bIsNotNull;
  69. bool m_bIsUnique;
  70. static string m_sPrimaryKeyString= "PRIMARY KEY";
  71. static string m_sNotNullString= "NOT NULL";
  72. static string m_sUniqueString= "UNIQUE";
  73. }
  74. }