private void ParseNestedObject(StreamReader reader, string line, MetaObject dbo) { string[] lines = line.Split(','); string fileName = lines[2].Replace("}", string.Empty); string objectName = lines[3].Replace("\"", string.Empty); MetaObject nested = new MetaObject() { Owner = dbo, Name = objectName, Parent = dbo.Parent }; dbo.MetaObjects.Add(nested); if (DBNames.TryGetValue(fileName, out DBNameEntry entry)) { DBName dbname = entry.DBNames.Where(i => i.Token == DBToken.VT).FirstOrDefault(); if (dbname != null) { nested.Token = dbname.Token; nested.TypeCode = dbname.TypeCode; nested.TableName = CreateTableName(nested, dbname); } } ParseNestedMetaProperties(reader, nested); }
private string CreateTableName(MetaObject metaObject, DBName dbname) { if (dbname.Token == DBToken.VT) { if (metaObject.Owner == null) { return(string.Empty); } else { return($"{metaObject.Owner.TableName}_{dbname.Token}{dbname.TypeCode}"); } } else { return($"_{dbname.Token}{dbname.TypeCode}"); } }
private void ParseDBNameLine(string line, Dictionary <string, DBNameEntry> dbnames) { string[] items = line.Split(','); if (items.Length < 3) { return; } string uuid = items[0].Substring(1); // .Replace("{", string.Empty); if (new Guid(uuid) == Guid.Empty) { return; // system meta object - global settings etc. } DBName dbname = new DBName() { Token = items[1].Trim('\"'), // .Replace("\"", string.Empty), TypeCode = int.Parse(items[2].TrimEnd('}')) // .Replace("}", string.Empty)) }; dbname.IsMainTable = IsMainTable(dbname.Token); if (!dbnames.TryGetValue(uuid, out DBNameEntry entry)) { entry = new DBNameEntry(); dbnames.Add(uuid, entry); } entry.DBNames.Add(dbname); if (dbname.IsMainTable) { entry.MetaObject.UUID = new Guid(uuid); entry.MetaObject.Token = dbname.Token; entry.MetaObject.TypeCode = dbname.TypeCode; entry.MetaObject.TableName = CreateTableName(entry.MetaObject, dbname); } }
private string CreateMetaFieldName(DBName dbname) { return($"{dbname.Token}{dbname.TypeCode}"); }
private void ParseDBNameLine(string line, Dictionary <string, DBNameEntry> dbnames) { string[] items = line.Split(','); if (items.Length < 3) { return; } string uuid = items[0].Substring(1); // .Replace("{", string.Empty); if (new Guid(uuid) == Guid.Empty) { return; // system meta object - global settings etc. } string token = items[1].Trim('\"'); if (token == MetadataTokens.Fld) { if (DBFields.ContainsKey(uuid)) { return; } DBNameEntry Fld = new DBNameEntry(); Fld.DBNames.Add(new DBName() { Token = token, TypeCode = int.Parse(items[2].TrimEnd('}')), IsMainTable = false }); DBFields.Add(uuid, Fld); return; } if (!IsTokenLoadingAllowed(token)) { return; } DBName dbname = new DBName() { Token = token, TypeCode = int.Parse(items[2].TrimEnd('}')) // .Replace("}", string.Empty)) }; dbname.IsMainTable = IsMainTable(dbname.Token); if (!dbnames.TryGetValue(uuid, out DBNameEntry entry)) { entry = new DBNameEntry(); dbnames.Add(uuid, entry); } entry.DBNames.Add(dbname); if (dbname.IsMainTable) { entry.MetaObject.UUID = new Guid(uuid); entry.MetaObject.TypeName = MapTokenToTypeName(dbname.Token); entry.MetaObject.TypeCode = dbname.TypeCode; entry.MetaObject.TableName = CreateTableName(entry.MetaObject, dbname); } }