public void HashData(object data) { if (!_byteExtractor.CanExtract(data.GetType())) { throw new InvalidOperationException("Cannot hash " + data.GetType()); } _byteExtractor.Extract(data, _stream); }
/// <inheritdoc /> public IHash Factory(object input) { if (!_byteExtractor.CanExtract(input.GetType())) { throw new ArgumentException(CannotHashMessage(input)); } using (var stream = new MemoryStream()) using (var safeStream = Stream.Synchronized(stream)) { _byteExtractor.Extract(input, safeStream); safeStream.Position = 0; return(new StreamHash(safeStream, _algorithmGenerator.Invoke())); } }
private bool CanExtractEnumerable(Type t) => typeof(IEnumerable).IsAssignableFrom(t) && _elementExtractor.CanExtract(t.GenericTypeArguments.Single());