Esempio n. 1
0
        /// <summary>
        /// Create a new stream wrapper
        /// </summary>
        /// <param name="stream">The underlying stream</param>
        /// <param name="start">The start position from where to read data</param>
        /// <param name="length">The length to read</param>
        public StreamSendWrapper(ThreadSafeStream stream, long start, long length)
        {
            if (start < 0)
            {
                throw new Exception("Provided start value cannot be less than 0.");
            }

            if (length < 0)
            {
                throw new Exception("Provided length value cannot be less than 0.");
            }

            this.ThreadSafeStream = stream;
            this.Start            = start;
            this.Length           = length;
        }
Esempio n. 2
0
        /// <summary>
        /// Return the MD5 for the specific part of the stream only.
        /// </summary>
        /// <returns></returns>
        public string MD5CheckSum()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                ThreadSafeStream.CopyTo(ms, Start, Length, 8000);

#if WINDOWS_PHONE
                using (var md5 = new DPSBase.MD5Managed())
                {
#else
                using (var md5 = System.Security.Cryptography.MD5.Create())
                {
#endif
                    return(BitConverter.ToString(md5.ComputeHash(ms)).Replace("-", ""));
                }
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Create a new stream wrapper and set Start and Length to encompass the entire Stream
 /// </summary>
 /// <param name="stream">The underlying stream</param>
 public StreamSendWrapper(ThreadSafeStream stream)
 {
     this.ThreadSafeStream = stream;
     this.Start            = 0;
     this.Length           = stream.Length;
 }
Esempio n. 4
0
 /// <summary>
 /// Dispose the internal ThreadSafeStream
 /// </summary>
 public void Dispose()
 {
     ThreadSafeStream.Dispose();
 }