public CDBTableType(string tableName, Dictionary <string, string> properties, IEnumerable <string> partition, IEnumerable <string> clustering, string ascorDesc) { TableName = tableName; propertiesString = properties; Properties = new Dictionary <string, CDBPropertyType>(); foreach (var item in properties) { CDBPropertyType ctype = default; var key = item.Key.TrimEnd('?'); switch (key) { case "string": ctype = CDBPropertyType.String; break; case "int": ctype = CDBPropertyType.Int32; break; case "byte": ctype = CDBPropertyType.Int8; break; case "short": ctype = CDBPropertyType.Int16; break; case "long": ctype = CDBPropertyType.Int64; break; case "object": ctype = CDBPropertyType.Object; break; case "array": ctype = CDBPropertyType.Array; break; case "dictionary": ctype = CDBPropertyType.Dictionary; break; } if (item.Key.EndsWith("?")) { ctype |= CDBPropertyType.Nullable; } } partitionKey = new HashSet <string>(partition); clusteringKey = new HashSet <string>(clustering); AscOrDesc = ascorDesc; }
private static Dictionary <string, string> FromProperties(Dictionary <string, CDBPropertyType> properties) { Dictionary <string, string> retVal = new Dictionary <string, string>(); foreach (var item in properties) { CDBPropertyType a = item.Value; bool nullable = false; string type = ""; if ((int)a > 128) { a -= CDBPropertyType.Nullable; nullable = true; } if (a == CDBPropertyType.Array) { type = "array"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.Dictionary) { type = "dictionary"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.Int16) { type = "short"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.Int32) { type = "int"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.Int64) { type = "long"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.Int8) { type = "byte"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.Object) { type = "object"; if (nullable) { type += "?"; } } else if (a == CDBPropertyType.String) { type = "string"; if (nullable) { type += "?"; } } retVal.Add(item.Key, type); } return(retVal); }