Beispiel #1
0
        public override bool Equals(object obj)
        {
            var other = obj as Document;

            if (Name != other.Name ||
                User.Name != other.User.Name ||
                Content != other.Content ||
                IndexNodes != other.IndexNodes ||
                IndexLeaves != other.IndexLeaves ||
                UserName != other.UserName)
            {
                return(false);
            }
            if (!NoMetadata &&
                !other.NoMetadata &&
                Metadatas.Count(m => m.Get(this) != null) > 1 &&
                Metadatas.Count(m => m.Get(other) != null) > 1 &&
                (Id != other.Id || Index != other.Index))
            {
                return(false);
            }
            if (Children?.Count != other.Children?.Count)
            {
                return(false);
            }
            if (Children != null)
            {
                foreach (var document in Children)
                {
                    var otherDocument = other.Children?.SingleOrDefault(o => o.Name == document.Name);
                    if (otherDocument == null || !document.Equals(otherDocument))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }