Exemplo n.º 1
0
        /// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
        /// <param name="other">An object to compare with this object.</param>
        /// <returns>true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.</returns>
        public bool Equals(DependenciesKeyword?other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }
            if (Requirements.Count != other.Requirements.Count)
            {
                return(false);
            }
            var byKey = Requirements.Join(other.Requirements,
                                          td => td.Key,
                                          od => od.Key,
                                          (td, od) => new { ThisDef = td.Value, OtherDef = od.Value })
                        .ToList();

            if (byKey.Count != Requirements.Count)
            {
                return(false);
            }

            return(byKey.All(g => Equals(g.ThisDef, g.OtherDef)));
        }