Ejemplo n.º 1
0
        /// <summary>
        /// Override of semantic equality between this and <paramref name="other"/>
        /// </summary>
        public override BL SemanticEquals(MARC.Everest.DataTypes.Interfaces.IAny other)
        {
            var baseEq = base.SemanticEquals(other);

            if (!(bool)baseEq)
            {
                return(baseEq);
            }

            // Null-flavored
            if (this.IsNull && other.IsNull)
            {
                return(true);
            }
            else if (this.IsNull ^ other.IsNull)
            {
                return(false);
            }

            // Values are equal?
            UVP <T> uvOther = other as UVP <T>;

            if (uvOther == null)
            {
                return(false);
            }
            return((this.Value == null ? uvOther.Value == null : this.Value.Equals(uvOther.Value)) &&
                   (this.Probability == null ? uvOther.Probability == null : this.Probability.Equals(uvOther.Probability)));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Determines semantic equality between this instance of NPPD and <paramref name="other"/>
        /// </summary>
        public override BL SemanticEquals(MARC.Everest.DataTypes.Interfaces.IAny other)
        {
            if (other == null)
            {
                return(null);
            }
            else if (this.IsNull && other.IsNull)
            {
                return new BL()
                       {
                           NullFlavor = NullFlavorUtil.CommonAncestorWith(this.NullFlavor, other.NullFlavor)
                       }
            }
            ;
            else if (this.IsNull ^ other.IsNull)
            {
                return new BL()
                       {
                           NullFlavor = DataTypes.NullFlavor.NotApplicable
                       }
            }
            ;
            else if (!other.GetType().IsGenericType ||
                     other.GetType().GetGenericTypeDefinition().Equals(typeof(NPPD <>)))
            {
                return(false);
            }

            // Items must be in both sets
            int  otherNppdCount = 0;
            bool isEqual        = true;

            foreach (object itm in (other as IEnumerable))
            {
                isEqual &= this.Items.Contains(itm as UVP <T>);
                otherNppdCount++;
            }
            return(isEqual && otherNppdCount.Equals(this.Items.Count));
        }