Exemplo n.º 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;
        }
Exemplo n.º 2
0
        private void AddNewChildRelation(Root root)
        {
            var rx = new RelationX_RowX_RowX(root.Get <RelationXRoot>(), true);

            // the data root implements undo/redo functionality
            ItemCreated.Record(root, rx);
            ItemLinked.Record(root, root.Get <Relation_StoreX_ChildRelation>(), TX, rx);
            ChildDelta -= 2;
        }
Exemplo n.º 3
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}");
            }
        }
Exemplo n.º 4
0
        internal void SetRelationName(RelationX_RowX_RowX rel, string value)
        {
            var relation_Store_ChildRelation  = Get <Relation_Store_ChildRelation>();
            var relation_Store_ParentRelation = Get <Relation_Store_ParentRelation>();

            var childName  = BlankName;
            var parentName = BlankName;

            if (relation_Store_ParentRelation.TryGetParent(rel, out Store childTable))
            {
                childName = childTable.Name;
            }
            if (relation_Store_ChildRelation.TryGetParent(rel, out Store parentTable))
            {
                parentName = parentTable.Name;
            }
            StringBuilder sb = new StringBuilder(value);

            sb.Replace(parentName + parentNameSuffix, "");
            sb.Replace(childName + childNameSuffix, "");
            sb.Replace(identitySuffix, "");
            rel.Name = sb.ToString();
        }
Exemplo n.º 5
0
 internal Model_6A7_ChildRelation(Model_6B3_ChildRelationList owner, RowX item, Relation rel) : base(owner, item)
 {
     _relation_RowX_RowX = rel as RelationX_RowX_RowX;
 }
Exemplo n.º 6
0
 internal Model_6A8_ParentRelation(Model_6B4_ParentRelationList owner, RowX item, Relation rel) : base(owner, item)
 {
     _relation_RowX_RowX = rel as RelationX_RowX_RowX;
 }