コード例 #1
0
        private void ReadConnections()
        {
            int      firstNumberOfFieldToconnect  = -1;
            int      secondNumberOfFieldToConnect = -1;
            MyString secondTableToConnect         = new MyString();

            for (int i = 0; i < CountOfTables; i++)
            {
                for (int j = 0; j < tables[i].Rows.Size; j++)
                {
                    MyString field             = tables[i].Rows[j].Data[0];
                    int      startConnectIndex = field.IndexOf(new MyString('['));
                    int      endConnectIndex   = field.IndexOf(new MyString(']'));
                    int      point             = field.IndexOf(new MyString(','));

                    if (startConnectIndex > 0)
                    {
                        firstNumberOfFieldToconnect  = j;
                        secondNumberOfFieldToConnect = field.Substring(point + 1, endConnectIndex - (point + 1)).GetInt();
                        secondTableToConnect         = field.Substring(startConnectIndex + 1, point - (startConnectIndex + 1));

                        tables[i].Rows[firstNumberOfFieldToconnect].SetConnection(GetNumberOfTable(secondTableToConnect), secondNumberOfFieldToConnect);

                        tables[i].RemoveBreakets(firstNumberOfFieldToconnect);
                    }
                }
            }
        }
コード例 #2
0
        public void Save()
        {
            Console.WriteLine("Saving the base...");
            for (int j = 0; j < CountOfTables; j++)
            {
                using (FileStream fstream = new FileStream($"{Name.GetString()} {tables[j].Name.GetString()}.txt", FileMode.OpenOrCreate))
                {
                    MyString     str  = new MyString();
                    MyList <Row> rows = GetRows(tables[j].Name);
                    for (int i = 0; i < rows.Size; i++)
                    {
                        if (!rows[i].IsConnected)
                        {
                            str += rows[i].Data[0] + new MyString(' ');
                        }
                        else
                        {
                            str += rows[i].Data[0] + new MyString('[') +
                                   GetNameOfTable(rows[i].NumberTableToConnect) + new MyString(',') +
                                   new MyString(rows[i].NumberFieldToConnect) + new MyString(']') + new MyString(' ');
                        }
                    }
                    str += new MyString('\n');

                    for (int k = 1; k < rows[0].Data.Size; k++)
                    {
                        for (int i = 0; i < rows.Size; i++)
                        {
                            str += rows[i].Data[k] + new MyString(' ');
                        }

                        str += new MyString('\n');
                    }
                    str = str.Substring(0, str.Length - 2);
                    byte[] array = System.Text.Encoding.Default.GetBytes(str.GetString());
                    fstream.Write(array, 0, array.Length);
                }
            }
            Console.WriteLine("Done.");
        }