/// <summary>
        /// Returns true if InlineObject instances are equal
        /// </summary>
        /// <param name="other">Instance of InlineObject to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(InlineObject other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProposalId == other.ProposalId ||
                     ProposalId != null &&
                     ProposalId.Equals(other.ProposalId)
                     ) &&
                 (
                     Times == other.Times ||
                     Times != null &&
                     Times.Equals(other.Times)
                 ) &&
                 (
                     Break == other.Break ||

                     Break.Equals(other.Break)
                 ));
        }
Example #2
0
        /// <summary>
        /// Adds the intensities from the other TimeIntensities to the intensities in this.
        /// The returned TimeIntensities whill have a set of times which is the union of the
        /// times in this and <paramref name="other"/>.
        /// </summary>
        public TimeIntensities MergeTimesAndAddIntensities(TimeIntensities other)
        {
            if (Times.Equals(other.Times))
            {
                return(AddIntensities(other));
            }
            var mergedTimes = ImmutableList.ValueOf(Times.Concat(other.Times).Distinct().OrderBy(time => time));

            if (mergedTimes.Equals(Times))
            {
                return(AddIntensities(other));
            }
            return(Interpolate(mergedTimes, false).AddIntensities(other));
        }
Example #3
0
 /// <summary>
 /// Adds the intensities from the other TimeIntensities to the intensities in this.
 /// The returned TimeIntensities will have the same set of times as this.
 /// </summary>
 public TimeIntensities AddIntensities(TimeIntensities other)
 {
     if (!Times.Equals(other.Times))
     {
         other = other.Interpolate(Times, false);
     }
     float[] newIntensities = new float[Times.Count];
     for (int i = 0; i < Times.Count; i++)
     {
         // Avoid arithmetic overflow
         double intensitySum = Intensities[i] + other.Intensities[i];
         newIntensities[i] = intensitySum < float.MaxValue ? (float)intensitySum : float.MaxValue;
     }
     return(new TimeIntensities(Times, newIntensities, null, null));
 }
Example #4
0
        public override bool Equals(object obj)
        {
            KdbxGroup other = obj as KdbxGroup;

            if (other == null)
            {
                return(false);
            }

            if (Parent != null)
            {
                if (other.Parent == null)
                {
                    return(false);
                }
                if (!Parent.Uuid.Equals(other.Parent.Uuid))
                {
                    return(false);
                }
            }
            else
            {
                if (other.Parent != null)
                {
                    return(false);
                }
            }

            if (!Uuid.Equals(other.Uuid))
            {
                return(false);
            }

            if (!Title.Equals(other.Title) || !Notes.Equals(other.Notes))
            {
                return(false);
            }

            if (IconID != other.IconID)
            {
                return(false);
            }

            if (CustomIconUuid != null)
            {
                if (!CustomIconUuid.Equals(other.CustomIconUuid))
                {
                    return(false);
                }
            }
            else
            {
                if (other.CustomIconUuid != null)
                {
                    return(false);
                }
            }

            if (!Times.Equals(other.Times))
            {
                return(false);
            }

            if (IsExpanded != other.IsExpanded || !LastTopVisibleEntry.Equals(other.LastTopVisibleEntry))
            {
                return(false);
            }

            if (DefaultAutoTypeSequence != other.DefaultAutoTypeSequence ||
                EnableAutoType != other.EnableAutoType ||
                EnableSearching != other.EnableSearching)
            {
                return(false);
            }

            int childCount = Children.Count;

            if (childCount != other.Children.Count)
            {
                return(false);
            }

            for (int i = 0; i < childCount; i++)
            {
                if (!Children[i].Equals(other.Children[i]))
                {
                    return(false);
                }
            }

            if (CustomData != null)
            {
                if (!CustomData.Equals(other.CustomData))
                {
                    return(false);
                }
            }
            else
            {
                if (other.CustomData != null)
                {
                    return(false);
                }
            }

            return(true);
        }
Example #5
0
        public override bool Equals(object obj)
        {
            KdbxEntry other = obj as KdbxEntry;

            if (other == null)
            {
                return(false);
            }

            if (Parent != null)
            {
                if (other.Parent == null || !Parent.Uuid.Equals(other.Parent.Uuid))
                {
                    return(false);
                }
            }
            else
            {
                if (other.Parent != null)
                {
                    return(false);
                }
            }

            DebugHelper.Assert(Uuid != null);
            if (!Uuid.Equals(other.Uuid))
            {
                return(false);
            }

            if (IconID != other.IconID)
            {
                return(false);
            }

            if (CustomIconUuid != null)
            {
                if (!CustomIconUuid.Equals(other.CustomIconUuid))
                {
                    return(false);
                }
            }
            else
            {
                if (other.CustomIconUuid != null)
                {
                    return(false);
                }
            }

            if (ForegroundColor != other.ForegroundColor || BackgroundColor != other.BackgroundColor)
            {
                return(false);
            }

            if (OverrideUrl != other.OverrideUrl)
            {
                return(false);
            }

            if (Tags != other.Tags)
            {
                return(false);
            }

            if (!Times.Equals(other.Times))
            {
                return(false);
            }

            if (!Title.Equals(other.Title) ||
                !UserName.Equals(other.UserName) ||
                !Password.Equals(other.Password) ||
                !Url.Equals(other.Url))
            {
                return(false);
            }

            if (Notes != null)
            {
                if (!Notes.Equals(other.Notes))
                {
                    return(false);
                }
            }
            else
            {
                if (other.Notes != null)
                {
                    return(false);
                }
            }

            if (Fields.Count != other.Fields.Count)
            {
                return(false);
            }

            for (int i = 0; i < Fields.Count; i++)
            {
                if (!Fields[i].Equals(other.Fields[i]))
                {
                    return(false);
                }
            }

            if (Binaries.Count != other.Binaries.Count)
            {
                return(false);
            }

            for (int i = 0; i < Binaries.Count; i++)
            {
                if (!Binaries[i].Equals(other.Binaries[i]))
                {
                    return(false);
                }
            }

            if (AutoType != null)
            {
                if (!AutoType.Equals(other.AutoType))
                {
                    return(false);
                }
            }
            else
            {
                if (other.AutoType != null)
                {
                    return(false);
                }
            }

            if (History != null)
            {
                DebugHelper.Assert(!this.isHistoryEntry);
                if (!History.Equals(other.History))
                {
                    return(false);
                }
            }
            else
            {
                if (other.History != null)
                {
                    return(false);
                }
            }

            if (CustomData != null)
            {
                if (!CustomData.Equals(other.CustomData))
                {
                    return(false);
                }
            }
            else
            {
                if (other.CustomData != null)
                {
                    return(false);
                }
            }

            return(true);
        }