예제 #1
0
        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);
        }
예제 #2
0
        private void ParseMetaProperty(StreamReader reader, string line, MetaObject dbo, MetaPropertyPurpose purpose)
        {
            string[] lines      = line.Split(',');
            string   fileName   = lines[2].Replace("}", string.Empty);
            string   objectName = lines[3].Replace("\"", string.Empty);

            MetaProperty property = new MetaProperty
            {
                Parent  = dbo,
                Name    = objectName,
                Purpose = purpose
            };

            dbo.Properties.Add(property);

            if (DBNames.TryGetValue(fileName, out DBNameEntry entry))
            {
                if (entry.DBNames.Count == 1)
                {
                    property.DbName = CreateMetaFieldName(entry.DBNames[0]);
                }
                else if (entry.DBNames.Count > 1)
                {
                    foreach (var dbn in entry.DBNames.Where(dbn => dbn.Token == DBToken.Fld))
                    {
                        property.DbName = CreateMetaFieldName(dbn);
                    }
                }
            }
            ParseMetaPropertyTypes(reader, property);
        }
예제 #3
0
        private void ParseAccumulationRegister(string fileName)
        {
            if (!DBNames.TryGetValue(fileName, out DBNameEntry entry))
            {
                return;
            }

            foreach (DBName dbname in entry.DBNames)
            {
                string name = GetChildMetaObjectName(dbname.Token);
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }
                entry.MetaObject.MetaObjects.Add(
                    new MetaObject()
                {
                    Name      = name,
                    Token     = dbname.Token,
                    Owner     = entry.MetaObject,
                    TypeCode  = dbname.TypeCode,
                    TableName = $"_{dbname.Token}{dbname.TypeCode}"
                });
            }
        }
예제 #4
0
        private void ParseReferenceOwner(StreamReader reader, MetaObject dbo)
        {
            int count = 0;

            string[] lines;

            string line = reader.ReadLine(); // 8. line

            if (line != null)
            {
                lines = line.Split(',');
                count = int.Parse(lines[1].Replace("}", string.Empty));
            }
            if (count == 0)
            {
                return;
            }

            Match           match;
            List <TypeInfo> types = new List <TypeInfo>();

            for (int i = 0; i < count; i++)
            {
                _    = reader.ReadLine();
                line = reader.ReadLine();
                if (line == null)
                {
                    return;
                }

                match = rxUUID.Match(line);
                if (match.Success)
                {
                    if (DBNames.TryGetValue(match.Value, out DBNameEntry entry))
                    {
                        types.Add(new TypeInfo()
                        {
                            TypeCode   = entry.MetaObject.TypeCode,
                            Name       = entry.MetaObject.TableName,
                            MetaObject = entry.MetaObject
                        });
                    }
                }
                _ = reader.ReadLine();
            }

            if (types.Count > 0)
            {
                MetaProperty property = new MetaProperty
                {
                    Parent = dbo,
                    Types  = types,
                    Name   = "Владелец",
                    DbName = "OwnerID" // [_OwnerIDRRef] | [_OwnerID_TYPE] + [_OwnerID_RTRef] + [_OwnerID_RRRef]
                                       // TODO: add DbField at once ?
                };
                dbo.Properties.Add(property);
            }
        }