Exemple #1
0
        internal bool CreateTestRelation(int tx1Index, int tx2Index, Pairing pairing)
        {
            if (IsInvalidTableIndex(tx1Index))
            {
                return(false);
            }
            if (IsInvalidTableIndex(tx2Index))
            {
                return(false);
            }

            var rx = new RelationX_RowX_RowX(Get <RelationXRoot>());

            rx.Pairing = pairing;
            rx.Initialize(NR, NR);

            var tx1 = Get <TableXRoot>().Items[tx1Index];
            var tx2 = Get <TableXRoot>().Items[tx2Index];

            Get <Relation_Store_ChildRelation>().SetLink(tx1, rx);
            Get <Relation_Store_ParentRelation>().SetLink(tx2, rx);

            for (int i = 0; i < NR; i++)
            {
                rx.SetLink(tx1.Items[i], tx2.Items[i]);
            }
            return(true);

            bool IsInvalidTableIndex(int txI) => (txI < 0) ? true : (txI < Get <TableXRoot>().Count) ? false : true;
        }
Exemple #2
0
        public void ReadData(DataReader r, Item[] items)
        {
            var N = r.ReadInt32();

            if (N < 0)
            {
                throw new Exception($"Invalid count {N}");
            }
            SetCapacity(N);

            var fv = r.ReadByte();

            if (fv == 1)
            {
                for (int i = 0; i < N; i++)
                {
                    var index = r.ReadInt32();
                    if (index < 0 || index >= items.Length)
                    {
                        throw new Exception($"RelationXStore ReadData, invalid index {index}");
                    }

                    var rx = new RelationX_RowX_RowX(this);
                    items[index] = rx;

                    var b = r.ReadByte();
                    if ((b & B1) != 0)
                    {
                        rx.SetState(r.ReadUInt16());
                    }
                    if ((b & B2) != 0)
                    {
                        rx.Name = Value.ReadString(r);
                    }
                    if ((b & B3) != 0)
                    {
                        rx.Summary = Value.ReadString(r);
                    }
                    if ((b & B4) != 0)
                    {
                        rx.Description = Value.ReadString(r);
                    }
                    if ((b & B5) != 0)
                    {
                        rx.Pairing = (Pairing)r.ReadByte();
                    }
                    var keyCount = ((b & B6) != 0) ? r.ReadInt32() : 0;
                    var valCount = ((b & B6) != 0) ? r.ReadInt32() : 0;
                    rx.Initialize(keyCount, valCount);
                }
            }
            else
            {
                throw new Exception($"RelationXStore ReadData, unknown format version: {fv}");
            }
        }