/// <inheritdoc/> protected override int GetHashCode(object item, ValuerChainer valuer) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (valuer == null) { throw new ArgumentNullException(nameof(valuer)); } Type type = item.GetType(); int hash = ValueComparer.BaseHash + type.GetHashCode(); foreach (PropertyInfo property in type.GetProperties(_scope).Where(p => p.CanRead)) { hash = hash * ValueComparer.HashMultiplier + valuer.GetHashCode(property.GetValue(item)); } foreach (FieldInfo field in type.GetFields(_scope)) { hash = hash * ValueComparer.HashMultiplier + valuer.GetHashCode(field.GetValue(item)); } return(hash); }
/// <inheritdoc/> protected override int GetHashCode(StringDictionary item, ValuerChainer valuer) { if (valuer == null) { throw new ArgumentNullException(nameof(valuer)); } return(valuer.GetHashCode(Convert(item))); }
/// <inheritdoc/> protected override int GetHashCode(Task item, ValuerChainer valuer) { if (valuer == null) { throw new ArgumentNullException(nameof(valuer)); } return(valuer.GetHashCode(ExtractResult(item))); }
/// <inheritdoc/> protected override int GetHashCode(IFaked item, ValuerChainer valuer) { if (valuer == null) { throw new ArgumentNullException(nameof(valuer)); } return(valuer.GetHashCode(item?.FakeMeta)); }
/// <inheritdoc cref="GetHashCode"/> /// <typeparam name="T">Item type being compared.</typeparam> private static async Task <int> GetHashCodeAsync <T>(IAsyncEnumerable <T> item, ValuerChainer valuer) { int hash = ValueComparer.BaseHash; await foreach (T current in item) { hash = hash * ValueComparer.HashMultiplier + valuer.GetHashCode(current); } return(hash); }
/// <inheritdoc/> protected override int GetHashCode(IDictionary item, ValuerChainer valuer) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (valuer == null) { throw new ArgumentNullException(nameof(valuer)); } int hash = ValueComparer.BaseHash; foreach (DictionaryEntry entry in item) { hash += valuer.GetHashCode(entry.Key, entry.Value); } return(hash); }
/// <inheritdoc/> protected override int GetHashCode(IEnumerable item, ValuerChainer valuer) { if (item == null) { throw new ArgumentNullException(nameof(item)); } if (valuer == null) { throw new ArgumentNullException(nameof(valuer)); } int hash = ValueComparer.BaseHash; foreach (object value in item) { hash = hash * ValueComparer.HashMultiplier + valuer.GetHashCode(value); } return(hash); }