예제 #1
0
 public void Extract(object instance, System.IO.Stream stream)
 {
     foreach (var element in (IEnumerable)instance)
     {
         _elementExtractor.Extract(element, stream);
     }
 }
예제 #2
0
        public void HashData(object data)
        {
            if (!_byteExtractor.CanExtract(data.GetType()))
            {
                throw new InvalidOperationException("Cannot hash " + data.GetType());
            }

            _byteExtractor.Extract(data, _stream);
        }
예제 #3
0
        /// <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()));
                }
        }