private void ParseInternalIdentifier(string line, MetaObject metaObject) { string[] items = line.Split(','); string uuid = (metaObject.Token == DBToken.Enum ? items[1] : items[3]); UUIDs.Add(uuid, metaObject); }
public void AddConnection(string uuid) { if (UUIDs == null) { UUIDs = new List <string>(); } UUIDs.Add(uuid); }
public bool HasUUID(string key) { return(UUIDs != null && UUIDs.Contains(key)); }
private void ParseMetaPropertyTypes(StreamReader reader, MetaProperty property) { string line = reader.ReadLine(); if (line == null) { return; } while (line != "{\"Pattern\",") { line = reader.ReadLine(); if (line == null) { return; } } Match match; while ((line = reader.ReadLine()) != null) { match = rxDbType.Match(line); if (!match.Success) { break; } int typeCode = 0; string typeName = string.Empty; string token = match.Value.Replace("{", string.Empty).Replace("\"", string.Empty); switch (token) { case DBToken.B: { typeCode = -1; typeName = "Boolean"; break; } case DBToken.S: { typeCode = -2; typeName = "String"; break; } case DBToken.D: { typeCode = -3; typeName = "DateTime"; break; } case DBToken.N: { typeCode = -4; typeName = "Numeric"; break; } } if (typeCode != 0) { property.Types.Add(new TypeInfo() { Name = typeName, TypeCode = typeCode }); } else { string[] lines = line.Split(','); string UUID = lines[1].Replace("}", string.Empty); if (UUID == "e199ca70-93cf-46ce-a54b-6edc88c3a296") { // ХранилищеЗначения - varbinary(max) property.Types.Add(new TypeInfo() { Name = "BLOB", TypeCode = -5 }); } else if (UUID == "fc01b5df-97fe-449b-83d4-218a090e681e") { // УникальныйИдентификатор - binary(16) property.Types.Add(new TypeInfo() { Name = "UUID", TypeCode = -6 }); } else if (UUIDs.TryGetValue(UUID, out MetaObject dbo)) { property.Types.Add(new TypeInfo() { Name = dbo.TableName, TypeCode = dbo.TypeCode, UUID = UUID, MetaObject = dbo }); property.PropertyTypes.Add(dbo.TypeCode); } else // UUID is not loaded yet - see MakeSecondPass procedure { // TODO: get type code some how ... property.Types.Add(new TypeInfo() { UUID = UUID }); property.PropertyTypes.Add(int.MaxValue); // костыль !? } } } }
public void MakeSecondPass(DatabaseInfo database) { foreach (var ns in database.BaseObjects) { foreach (var dbo in ns.MetaObjects) { foreach (var property in dbo.Properties) { foreach (var type in property.Types) { if (type.TypeCode == 0) { if (type.MetaObject == null) { if (!string.IsNullOrEmpty(type.UUID)) { if (UUIDs.TryGetValue(type.UUID, out MetaObject dbObject)) { type.Name = dbObject.TableName; type.MetaObject = dbObject; type.TypeCode = dbObject.TypeCode; } } } else { type.Name = type.MetaObject.TableName; type.TypeCode = type.MetaObject.TypeCode; } } } } foreach (var nested in dbo.MetaObjects) { foreach (var property in nested.Properties) { foreach (var type in property.Types) { if (type.TypeCode == 0) { if (type.MetaObject == null) { if (!string.IsNullOrEmpty(type.UUID)) { if (UUIDs.TryGetValue(type.UUID, out MetaObject dbObject)) { type.Name = dbObject.TableName; type.MetaObject = dbObject; type.TypeCode = dbObject.TypeCode; } } } else { type.Name = type.MetaObject.TableName; type.TypeCode = type.MetaObject.TypeCode; } } } } } } } }