コード例 #1
0
ファイル: DocumentData.cs プロジェクト: science-docs/Docdown
        public DocumentData(IEnumerable <Reference> references) : this()
        {
            if (references is null)
            {
                throw new System.ArgumentNullException(nameof(references));
            }

            foreach (var reference in references)
            {
                if (!ReferenceMap.ContainsKey(reference.Label))
                {
                    ReferenceMap.Add(reference.Label, reference);
                }
            }
        }
コード例 #2
0
ファイル: HashTest.cs プロジェクト: VikKol/commonsfornet
        public void TestReferenceMap()
        {
            var orderList = new List <Order>();

            for (var i = 0; i < 10000; i++)
            {
                orderList.Add(new Order {
                    Id = i, Name = i.ToString()
                });
            }
            var map = new ReferenceMap <Order, Bill>();

            foreach (var order in orderList)
            {
                map.Add(order, new Bill {
                    Id = order.Id, Count = order.Id
                });
            }

            foreach (var order in orderList)
            {
                Assert.True(map.ContainsKey(order));
            }

            foreach (var order in orderList)
            {
                Assert.Equal(order.Id, map[order].Id);
                Assert.Equal(order.Id, map[order].Count);
            }

            var newOrderList = new List <Order>();

            for (var i = 0; i < 10000; i++)
            {
                orderList.Add(new Order {
                    Id = i, Name = i.ToString()
                });
            }

            foreach (var order in newOrderList)
            {
                Assert.False(map.ContainsKey(order));
            }
        }
コード例 #3
0
        private void BuildEdgeMaps()
        {
            currentParentEdges.Clear();
            originalChildEdges.Clear();
            originalChildReferences.Clear();
            var list = new List <TrackedObject>(tracker.GetInterestingObjects());

            foreach (var item in list)
            {
                var isNew = item.IsNew;
                var type  = item.Type;
                foreach (var association in type.Associations)
                {
                    if (association.IsForeignKey)
                    {
                        var otherItem  = GetOtherItem(association, item.Current);
                        var otherItem2 = GetOtherItem(association, item.Original);
                        var flag       = (otherItem != null && otherItem.IsDeleted) || (otherItem2?.IsDeleted ?? false);
                        var flag2      = otherItem?.IsNew ?? false;
                        if ((isNew | flag | flag2) || HasAssociationChanged(association, item))
                        {
                            if (otherItem != null)
                            {
                                currentParentEdges.Add(association, item, otherItem);
                            }
                            if (otherItem2 != null)
                            {
                                if (association.IsUnique)
                                {
                                    originalChildEdges.Add(association, otherItem2, item);
                                }
                                originalChildReferences.Add(otherItem2, item);
                            }
                        }
                    }
                }
            }
        }