Пример #1
0
        public static TDocumentItem FindMatchByUrl <TDocumentItem>(this IEnumerable <TDocumentItem> source, string url)
            where TDocumentItem : class, IDocumentItem
        {
            DocumentReference documentReference            = DocumentReference.Create(url);
            IIndexedHashSet <TDocumentItem> tDocumentItems = source as IIndexedHashSet <TDocumentItem>;

            if (tDocumentItems != null)
            {
                return(tDocumentItems[documentReference.GetHashCode()]);
            }
            return(source.FirstOrDefault <TDocumentItem>((TDocumentItem d) => d.DocumentReference.GetHashCode() == documentReference.GetHashCode()));
        }
Пример #2
0
        public void EqualsShouldCheckTitleAndAuthor()
        {
            var left = new DocumentReference {
                Title = "a", Author = "b"
            };
            var right = new DocumentReference {
                Title = "a", Author = "b"
            };

            Assert.AreEqual(left, right);
            Assert.IsTrue(left.Equals(right));
            Assert.AreEqual(left.GetHashCode(), right.GetHashCode());
        }
Пример #3
0
 public override int GetHashCode()
 {
     return(_documentReference?.GetHashCode() ?? 0);
 }