/// <summary> /// Serves as the default hash function. /// </summary> /// <returns> /// A hash code for the current object. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { var propertyHash = Evaluate.GenerateHashCode(this, ComparisonProperties); var valuesHash = Evaluate.GenerateHashCode(this.FormSubmissionValues.OrderBy(x => x.UnifiedField.Name)); return(Evaluate.GenerateHashCode(propertyHash, valuesHash)); }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns> /// A hash code for the current object. /// </returns> /// <filterpriority>2</filterpriority> public override int GetHashCode() { var propertyHash = Evaluate.GenerateHashCode(this, ComparisonProperties); var valuesHash = Evaluate.GenerateHashCode(this.FieldValues); return(Evaluate.GenerateHashCode(propertyHash, valuesHash)); }
public void GenerateHashCode_WithParamsArray_MatchesExpected() { var values = new object[] { DateTime.Today, 2342, "asdsdfa2342345" }; var expected = values.Aggregate(0, (i, o) => (i * 397) + Evaluate.GetHashCode(o)); var actual = Evaluate.GenerateHashCode(values); Assert.AreEqual(expected, actual); }
public void GenerateHashCode_WithObjectEnumerable_MatchesExpected() { IEnumerable <object> values = Array.Empty <object>(); var expected = values.Aggregate(0, (i, o) => (i * 397) + Evaluate.GetHashCode(o)); var actual = Evaluate.GenerateHashCode(values); Assert.AreEqual(expected, actual); }
/// <summary> /// When overridden in a derived class, serves as a hash function for the specified object for hashing algorithms and data structures, /// such as a hash table. /// </summary> /// <param name="obj"> /// The object for which to get a hash code. /// </param> /// <returns> /// A hash code for the specified object. /// </returns> public override int GetHashCode(EntityAttributeDefinition obj) { return(Evaluate.GenerateHashCode( obj, new List <Func <EntityAttributeDefinition, object> > { item => item.ReferenceName })); }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns> /// A hash code for the current object. /// </returns> public override int GetHashCode() { var sourceProperty = this.SourceExpression?.GetProperty(); var relationProperty = this.RelationExpression?.GetProperty(); return(Evaluate.GenerateHashCode( sourceProperty?.PropertyType, sourceProperty?.Name, this.SourceEntityAlias, relationProperty?.PropertyType, relationProperty?.Name, this.RelationEntityAlias)); }
public void GenerateHashCode_WithSelectors_MatchesExpected() { var item = new FakeTestItem { TestDateTime = DateTime.Today, TestInt = 2342, TestString = "asdsdfa2342345" }; IEnumerable <Func <FakeTestItem, object> > selectors = new Func <FakeTestItem, object>[] { dest => dest.TestDateTime, dest => dest.TestInt, dest => dest.TestString }; var expected = new object[] { item.TestDateTime, item.TestInt, item.TestString }.Aggregate( 0, (i, o) => (i * 397) + Evaluate.GetHashCode(o)); var actual = Evaluate.GenerateHashCode(item, selectors); Assert.AreEqual(expected, actual); }
/// <summary> /// Initializes a new instance of the <see cref="PocoDataRequest"/> class. /// </summary> /// <param name="dataReader"> /// The data reader. /// </param> /// <param name="attributeDefinitions"> /// The attribute definitions. /// </param> /// <param name="databaseContext"> /// The database context for the request. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="dataReader"/> or <paramref name="attributeDefinitions"/> is null. /// </exception> public PocoDataRequest( [NotNull] IDataReader dataReader, [NotNull] IEnumerable <EntityAttributeDefinition> attributeDefinitions, [NotNull] IDatabaseContext databaseContext) { if (attributeDefinitions == null) { throw new ArgumentNullException(nameof(attributeDefinitions)); } this.DataReader = dataReader ?? throw new ArgumentNullException(nameof(dataReader)); this.DatabaseContext = databaseContext ?? throw new ArgumentNullException(nameof(databaseContext)); this.FieldCount = dataReader.FieldCount; this.attributeDefinitions.AddRange(attributeDefinitions); // We need a unique hash for each query formation. this.hashObjects = this.GetHashObjects(typeof(object).FullName); this.hashCode = Evaluate.GenerateHashCode(this.hashObjects); this.toStringText = $"{typeof(object).FullName}:{string.Join(",", this.hashObjects.Skip(1))}"; }
/// <summary> /// Serves as the default hash function. /// </summary> /// <returns> /// A hash code for the current object. /// </returns> public override int GetHashCode() { return(Evaluate.GenerateHashCode(this, ComparisonProperties)); }
/// <summary> /// Creates hash code. /// </summary> /// <returns> /// The hash code for this value as an <see cref="int" />. /// </returns> private int CreateHashCode() { return(Evaluate.GenerateHashCode(this, ComparisonProperties)); }
/// <summary> /// When overridden in a derived class, serves as a hash function for the specified object for hashing algorithms /// and data structures, such as a hash table. /// </summary> /// <returns>A hash code for the specified object.</returns> /// <param name="obj">The object for which to get a hash code.</param> /// <exception cref="ArgumentNullException"> /// The type of <paramref name="obj" /> is a reference type and /// <paramref name="obj" /> is null. /// </exception> public override int GetHashCode(EntityLocation obj) { return(Evaluate.GenerateHashCode(obj.EntityType, obj.Alias, obj.Name, obj.Container)); }