public override int GetHashCode() { int hash = HashCodeHelper.Initialize(); hash = HashCodeHelper.Hash(hash, Id); hash = HashCodeHelper.Hash(hash, tailZoneStart); hash = HashCodeHelper.Hash(hash, firstTailZoneInterval); hash = HashCodeHelper.Hash(hash, tailZone); foreach (var period in periods) { hash = HashCodeHelper.Hash(hash, period); } return(hash); }
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.Id) .Hash(this.ColumnsSpanned) .Hash(this.Details) .Hash(this.Validation) .Hash(this.ValidationEvents) .Hash(this.DefaultAvailability) .Hash(this.AvailabilityCheckEvents) .Hash(this.AvailabilityCheck) .Hash(this.InputEvents) .Hash(this.ValueFormat) .Hash(this.Format) .Hash(this.HoverOver) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentArrayOfNullableBoolProperty) .Hash(this.ParentArrayOfNullableIntProperty) .Hash(this.ParentArrayOfNullableGuidProperty) .Hash(this.ParentArrayOfNullableDateTimeProperty) .Hash(this.ParentArrayOfNullableCustomEnumProperty) .Hash(this.ParentArrayOfNullableCustomFlagsEnumProperty) .Hash(this.Child1ArrayOfNullableBoolProperty) .Hash(this.Child1ArrayOfNullableIntProperty) .Hash(this.Child1ArrayOfNullableGuidProperty) .Hash(this.Child1ArrayOfNullableDateTimeProperty) .Hash(this.Child1ArrayOfNullableCustomEnumProperty) .Hash(this.Child1ArrayOfNullableCustomFlagsEnumProperty) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentReadOnlyListInterfaceOfNullableBoolProperty) .Hash(this.ParentReadOnlyListInterfaceOfNullableIntProperty) .Hash(this.ParentReadOnlyListInterfaceOfNullableGuidProperty) .Hash(this.ParentReadOnlyListInterfaceOfNullableDateTimeProperty) .Hash(this.ParentReadOnlyListInterfaceOfNullableCustomEnumProperty) .Hash(this.ParentReadOnlyListInterfaceOfNullableCustomFlagsEnumProperty) .Hash(this.Child2ReadOnlyListInterfaceOfNullableBoolProperty) .Hash(this.Child2ReadOnlyListInterfaceOfNullableIntProperty) .Hash(this.Child2ReadOnlyListInterfaceOfNullableGuidProperty) .Hash(this.Child2ReadOnlyListInterfaceOfNullableDateTimeProperty) .Hash(this.Child2ReadOnlyListInterfaceOfNullableCustomEnumProperty) .Hash(this.Child2ReadOnlyListInterfaceOfNullableCustomFlagsEnumProperty) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.DatabaseName) .Hash(this.DatabaseType) .Hash(this.RecoveryMode) .Hash(this.DataFileLogicalName) .Hash(this.DataFilePath) .Hash(this.LogFilePath) .Hash(this.DataFileCurrentSizeInKb) .Hash(this.DataFileMaxSizeInKb) .Hash(this.DataFileGrowthSizeInKb) .Hash(this.LogFileLogicalName) .Hash(this.LogFileCurrentSizeInKb) .Hash(this.LogFileMaxSizeInKb) .Hash(this.LogFileGrowthSizeInKb) .Value;
/// <summary> /// Returns the hash code for this period, consistent with <see cref="Equals(Period)"/>. /// </summary> /// <returns>The hash code for this period.</returns> public override int GetHashCode() { int hash = HashCodeHelper.Initialize(); hash = HashCodeHelper.Hash(hash, years); hash = HashCodeHelper.Hash(hash, months); hash = HashCodeHelper.Hash(hash, weeks); hash = HashCodeHelper.Hash(hash, days); hash = HashCodeHelper.Hash(hash, hours); hash = HashCodeHelper.Hash(hash, minutes); hash = HashCodeHelper.Hash(hash, seconds); hash = HashCodeHelper.Hash(hash, milliseconds); hash = HashCodeHelper.Hash(hash, ticks); return(hash); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data /// structures like a hash table. /// </returns> public override int GetHashCode() { var hash = HashCodeHelper.Initialize() .Hash(Name) .Hash(StandardOffset) .Hash(Rules) .Hash(Format) .Hash(UntilYear); if (UntilYear != Int32.MaxValue) { hash = hash.Hash(UntilYearOffset.GetHashCode()); } return(hash.Value); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data /// structures like a hash table. /// </returns> public override int GetHashCode() { int hash = HashCodeHelper.Initialize(); hash = HashCodeHelper.Hash(hash, Name); hash = HashCodeHelper.Hash(hash, Offset); hash = HashCodeHelper.Hash(hash, Rules); hash = HashCodeHelper.Hash(hash, Format); hash = HashCodeHelper.Hash(hash, UntilYear); if (UntilYear != Int32.MaxValue) { hash = HashCodeHelper.Hash(hash, UntilYearOffset.GetHashCode()); } return(hash); }
public static void HashElements___Should_return_different_hash_codes_for_two_different_IEnumerable___When_both_IEnumerable_are_not_sequence_equal() { // Arrange var values1a = new List <double?> { null }; var values1b = new double?[] { }; var values2a = new List <double?> { null }; var values2b = new double?[] { ThreadSafeRandom.NextDouble() }; var values3a = new[] { ThreadSafeRandom.NextDouble() }; var values3b = new List <double> { values3a[0], ThreadSafeRandom.NextDouble() }; var values4a = Enumerable.Range(0, 5).Select(_ => ThreadSafeRandom.NextDouble()).ToArray(); var values4b = new List <double>(values3a.Take(4)); var values5a = new double?[] { ThreadSafeRandom.NextDouble(), null, ThreadSafeRandom.NextDouble() }; var values5b = values5a.Reverse(); // Act var systemUnderTest1a = HashCodeHelper.Initialize().HashElements(values1a); var systemUnderTest1b = HashCodeHelper.Initialize().HashElements(values1b); var systemUnderTest2a = HashCodeHelper.Initialize().HashElements(values2a); var systemUnderTest2b = HashCodeHelper.Initialize().HashElements(values2b); var systemUnderTest3a = HashCodeHelper.Initialize().HashElements(values3a); var systemUnderTest3b = HashCodeHelper.Initialize().HashElements(values3b); var systemUnderTest4a = HashCodeHelper.Initialize().HashElements(values4a); var systemUnderTest4b = HashCodeHelper.Initialize().HashElements(values4b); var systemUnderTest5a = HashCodeHelper.Initialize().HashElements(values5a); var systemUnderTest5b = HashCodeHelper.Initialize().HashElements(values5b); // Assert systemUnderTest1a.Value.Should().NotBe(systemUnderTest1b.Value); systemUnderTest2a.Value.Should().NotBe(systemUnderTest2b.Value); systemUnderTest3a.Value.Should().NotBe(systemUnderTest3b.Value); systemUnderTest4a.Value.Should().NotBe(systemUnderTest4b.Value); systemUnderTest5a.Value.Should().NotBe(systemUnderTest5b.Value); }
/// <inheritdoc /> public int GetHashCode( Type obj) { if (obj == null) { throw new ArgumentNullException(nameof(obj)); } var result = HashCodeHelper .Initialize() .Hash(obj.GetFullyNestedName()) .Hash(obj.Namespace) .Hash(obj.Assembly.GetName().Name) .Value; return(result); }
public int GetHashCode(ZoneInterval obj) { var hash = HashCodeHelper.Initialize(); if (CheckOption(options, Options.MatchOffsetComponents)) { hash = hash.Hash(obj.StandardOffset).Hash(obj.Savings); } else { hash = hash.Hash(obj.WallOffset); } if (CheckOption(options, Options.MatchNames)) { hash = hash.Hash(obj.Name); } return(hash.Hash(GetEffectiveStart(obj)).Hash(GetEffectiveEnd(obj)).Value); }
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentReadOnlyDictionaryInterfaceOfBoolProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfIntProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfStringProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfGuidProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfCustomEnumProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfCustomFlagsEnumProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfCustomClassProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfCustomBaseClassProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfCustomGenericClassOfCustomClassProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfBoolProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfIntProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfStringProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfGuidProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfCustomEnumProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfCustomFlagsEnumProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfCustomClassProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfCustomBaseClassProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfCustomGenericClassOfCustomClassProperty) .Value;
public static void Hash___Should_return_same_hash_code___When_the_values_to_hash_are_equal_and_hashed_in_same_order() { // Arrange var value1a = "some string"; var value1b = "some string"; var value2a = "some other string"; var value2b = "some other string"; // Act var systemUnderTest1a = HashCodeHelper.Initialize().Hash(value1a); var systemUnderTest1b = HashCodeHelper.Initialize().Hash(value1b); var systemUnderTest2a = HashCodeHelper.Initialize().Hash(value1a).Hash(value2a); var systemUnderTest2b = HashCodeHelper.Initialize().Hash(value1b).Hash(value2b); // Assert systemUnderTest1a.Value.Should().Be(systemUnderTest1b.Value); systemUnderTest2a.Value.Should().Be(systemUnderTest2b.Value); }
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentArrayOfBoolProperty) .Hash(this.ParentArrayOfIntProperty) .Hash(this.ParentArrayOfStringProperty) .Hash(this.ParentArrayOfGuidProperty) .Hash(this.ParentArrayOfDateTimeProperty) .Hash(this.ParentArrayOfCustomEnumProperty) .Hash(this.ParentArrayOfCustomFlagsEnumProperty) .Hash(this.ParentArrayOfCustomClassProperty) .Hash(this.ParentArrayOfCustomBaseClassProperty) .Hash(this.ParentArrayOfCustomGenericClassOfCustomClassProperty) .Hash(this.Child2ArrayOfBoolProperty) .Hash(this.Child2ArrayOfIntProperty) .Hash(this.Child2ArrayOfStringProperty) .Hash(this.Child2ArrayOfGuidProperty) .Hash(this.Child2ArrayOfDateTimeProperty) .Hash(this.Child2ArrayOfCustomEnumProperty) .Hash(this.Child2ArrayOfCustomFlagsEnumProperty) .Hash(this.Child2ArrayOfCustomClassProperty) .Hash(this.Child2ArrayOfCustomBaseClassProperty) .Hash(this.Child2ArrayOfCustomGenericClassOfCustomClassProperty) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentCollectionInterfaceOfStringProperty) .Hash(this.ParentListInterfaceOfStringProperty) .Hash(this.ParentReadOnlyCollectionInterfaceOfCollectionInterfaceOfStringProperty) .Hash(this.ParentCollectionInterfaceOfReadOnlyListInterfaceOfStringProperty) .Hash(this.ParentListInterfaceOfCollectionInterfaceOfStringProperty) .Hash(this.ParentReadOnlyListInterfaceOfListInterfaceOfStringProperty) .Hash(this.ParentDictionaryInterfaceOfReadOnlyListInterfaceOfDateTimeProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfCollectionInterfaceOfDateTimeProperty) .Hash(this.ParentReadOnlyListInterfaceOfReadOnlyDictionaryInterfaceOfReadOnlyListInterfaceOfDateTimeProperty) .Hash(this.ParentReadOnlyDictionaryInterfaceOfReadOnlyDictionaryInterfaceOfDictionaryInterfaceOfReadOnlyListInterfaceOfDateTimeProperty) .Hash(this.Child2CollectionInterfaceOfStringProperty) .Hash(this.Child2ListInterfaceOfStringProperty) .Hash(this.Child2ReadOnlyCollectionInterfaceOfCollectionInterfaceOfStringProperty) .Hash(this.Child2CollectionInterfaceOfReadOnlyListInterfaceOfStringProperty) .Hash(this.Child2ListInterfaceOfCollectionInterfaceOfStringProperty) .Hash(this.Child2ReadOnlyListInterfaceOfListInterfaceOfStringProperty) .Hash(this.Child2DictionaryInterfaceOfReadOnlyListInterfaceOfDateTimeProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfCollectionInterfaceOfDateTimeProperty) .Hash(this.Child2ReadOnlyListInterfaceOfReadOnlyDictionaryInterfaceOfReadOnlyListInterfaceOfDateTimeProperty) .Hash(this.Child2ReadOnlyDictionaryInterfaceOfReadOnlyDictionaryInterfaceOfDictionaryInterfaceOfReadOnlyListInterfaceOfDateTimeProperty) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentBoolProperty) .Hash(this.ParentIntProperty) .Hash(this.ParentStringProperty) .Hash(this.ParentGuidProperty) .Hash(this.ParentDateTimeProperty) .Hash(this.ParentCustomEnumProperty) .Hash(this.ParentCustomFlagsEnumProperty) .Hash(this.ParentCustomClassProperty) .Hash(this.ParentCustomBaseClassProperty) .Hash(this.ParentCustomGenericClassOfCustomClassProperty) .Hash(this.Child2BoolProperty) .Hash(this.Child2IntProperty) .Hash(this.Child2StringProperty) .Hash(this.Child2GuidProperty) .Hash(this.Child2DateTimeProperty) .Hash(this.Child2CustomEnumProperty) .Hash(this.Child2CustomFlagsEnumProperty) .Hash(this.Child2CustomClassProperty) .Hash(this.Child2CustomBaseClassProperty) .Hash(this.Child2CustomGenericClassOfCustomClassProperty) .Value;
public int GetHashCode( IEnumerable <T> obj) { int result; var hashCodeHelper = HashCodeHelper.Initialize(); switch (this.enumerableEqualityComparerStrategy) { case EnumerableEqualityComparerStrategy.SequenceEqual: result = hashCodeHelper.HashElements(obj).Value; break; case EnumerableEqualityComparerStrategy.NoSymmetricDifference: result = hashCodeHelper.HashElements(obj.Distinct().OrderBy(_ => _)).Value; break; default: throw new NotSupportedException(Invariant($"This {nameof(EnumerableEqualityComparerStrategy)} is not supported: {this.enumerableEqualityComparerStrategy}.")); } return(result); }
public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ObjectProperty) .Hash(this.StringProperty) .Hash(this.VersionProperty) .Hash(this.UriProperty) .Hash(this.TestInterfaceClassProperty) .Hash(this.TestArrayProperty) .Hash(this.DictionaryProperty) .Hash(this.DictionaryInterfaceProperty) .Hash(this.ReadOnlyDictionaryProperty) .Hash(this.ReadOnlyDictionaryInterfaceProperty) .Hash(this.ConcurrentDictionaryProperty) .Hash(this.CollectionProperty) .Hash(this.CollectionInterfaceProperty) .Hash(this.ReadOnlyCollectionProperty) .Hash(this.ReadOnlyCollectionInterfaceProperty) .Hash(this.ListProperty) .Hash(this.ListInterfaceProperty) .Hash(this.ReadOnlyListInterfaceProperty) .Hash(this.ObjectStringProperty) .Hash(this.ObjectVersionProperty) .Hash(this.ObjectUriProperty) .Hash(this.ObjectTestInterfaceClassProperty) .Hash(this.ObjectTestArrayProperty) .Hash(this.ObjectDictionaryProperty) .Hash(this.ObjectDictionaryInterfaceProperty) .Hash(this.ObjectReadOnlyDictionaryProperty) .Hash(this.ObjectReadOnlyDictionaryInterfaceProperty) .Hash(this.ObjectConcurrentDictionaryProperty) .Hash(this.ObjectCollectionProperty) .Hash(this.ObjectCollectionInterfaceProperty) .Hash(this.ObjectReadOnlyCollectionProperty) .Hash(this.ObjectReadOnlyCollectionInterfaceProperty) .Hash(this.ObjectListProperty) .Hash(this.ObjectListInterfaceProperty) .Hash(this.ObjectReadOnlyListInterfaceProperty) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize(this.GetBaseHashCode()) .Hash(this.TimeSlicePerFile) .Hash(this.FileNamePrefix) .Hash(this.LogFileDirectoryPath) .Hash(this.CreateDirectoryStructureIfMissing) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.Minute) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.EmailParticipants) .Hash(this.EmailContent) .Hash(this.EmailOptions) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.Name) .Hash(this.Cell) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.TimestampUtc) .Hash(this.Id) .Hash(this.SendEmailResponse) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.OuterBorders) .Hash(this.InnerBorders) .Hash(this.RowsFormat) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.Kind) .Hash(this.Granularity) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.TimestampUtc) .Hash(this.Id) .Hash(this.AttemptToSendNotificationResult) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.Statements) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.StreamRepresentation) .Hash(this.RecordExists) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.DaysOfMonth) .Hash(this.Hour) .Hash(this.Minute) .Value;
/// <inheritdoc /> public override int GetHashCode() => HashCodeHelper.Initialize() .Hash(this.ParentInt) .Hash(this.Child2Int) .Hash(this.Grandchild2AInt) .Value;