1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace OTSModelSharp.DTLBase
- {
- public class ColumnType
- {
-
- public enum ID
- {
- MIN = 0,
- INTEGER = 0,
- FLOAT = 1,
- STRING = 2,
- BLOB = 3,
- NONE = 4,
- MAX = 4
- };
-
- public ColumnType( ID a_nTypeId,
-
- bool a_bIsNotNull = false,
- bool a_bIsUnique = false)
- {
- m_nTypeId = a_nTypeId;
-
- m_bIsNotNull = a_bIsNotNull;
- m_bIsUnique = a_bIsUnique;
- }
- ~ColumnType()
- { }
- public ID GetTypeId() { return m_nTypeId; }
- public bool IsIsNotNull() { return m_bIsNotNull; }
- public bool IsIsUnique() { return m_bIsUnique; }
- public string GetName()
- {
- return GetTypeId().ToString();
- }
-
- public string GetFormat(int position)
- {
- int nId =(int) GetTypeId();
- string sRet;
- switch (nId)
- {
- case (int)ColumnType.ID.INTEGER:
- sRet = "{"+position.ToString()+":G}";
- break;
- case (int)ColumnType.ID.FLOAT:
- sRet = "{" + position.ToString() + ":G}";
- break;
- case (int)ColumnType.ID.STRING:
- sRet = "\"{" + position.ToString() + ":G}\"";
- break;
- case (int)ColumnType.ID.BLOB:
- sRet = "@blob";
- break;
- case (int)ColumnType.ID.NONE:
- sRet = "\"{" + position.ToString() + ":G}\"";
- break;
- default:
- sRet = "\"{" + position.ToString() + ":G}\"";
- break;
- }
- return sRet;
- }
- static string PrimaryKeyString() { return m_sPrimaryKeyString; }
- static string NotNullString() { return m_sNotNullString; }
- static string UniqueString() { return m_sUniqueString; }
- ID m_nTypeId;
- bool m_bIsNotNull;
- bool m_bIsUnique;
- static string m_sPrimaryKeyString= "PRIMARY KEY";
- static string m_sNotNullString= "NOT NULL";
- static string m_sUniqueString= "UNIQUE";
- }
- }
|