Ejemplo n.º 1
0
 //
 // Summary:
 //     Skip response data when requested by a Range header. Skip over and discard bytesToSkip
 //     bytes of response data. - If data is available immediately set bytesSkipped to
 //     the number of of bytes skipped and return true. - To read the data at a later
 //     time set bytesSkipped to 0, return true and execute callback when the data is
 //     available. - To indicate failure set bytesSkipped to < 0 (e.g. -2 for ERR_FAILED)
 //     and return false. This method will be called in sequence but not from a dedicated
 //     thread.
 //
 // Parameters:
 //   bytesToSkip:
 //     number of bytes to be skipped
 //
 //   bytesSkipped:
 //     If data is available immediately set bytesSkipped to the number of of bytes skipped
 //     and return true. To read the data at a later time set bytesSkipped to 0, return
 //     true and execute callback when the data is available.
 //
 //   callback:
 //     To read the data at a later time set bytesSkipped to 0, return true and execute
 //     callback when the data is available.
 //
 // Returns:
 //     See summary
 public bool Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     // To indicate failure set bytesSkipped to < 0 (e.g. -2 for ERR_FAILED)
     //     and return false.
     bytesSkipped = -2;
     return(false);
 }
        bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
        {
            //We don't need the callback, as it's an unmanaged resource we should dispose it (could wrap it in a using statement).
            callback.Dispose();

            //No Stream or Stream cannot seek then we indicate failure
            if (stream == null || !stream.CanSeek)
            {
                //Indicate failure
                bytesSkipped = -2;

                return(false);
            }

            if (stream.Position == (stream.Length - 1))
            {
                bytesSkipped = 0;

                return(true);
            }

            var oldPosition = stream.Position;

            var position = stream.Seek(bytesToSkip, SeekOrigin.Current);

            bytesSkipped = position - oldPosition;

            return(true);
        }
Ejemplo n.º 3
0
        bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
        {
            //No Stream or Stream cannot seek then we indicate failure
            if (stream == null || !stream.CanSeek)
            {
                //Indicate failure
                bytesSkipped = -2;

                return(false);
            }

            if (stream.Position == (stream.Length - 1))
            {
                bytesSkipped = 0;

                return(true);
            }

            var oldPosition = stream.Position;

            var position = stream.Seek(bytesToSkip, SeekOrigin.Current);

            bytesSkipped = position - oldPosition;

            return(true);
        }
Ejemplo n.º 4
0
        bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
        {
            if (_stream == null || !_stream.CanSeek)
            {
                bytesSkipped = -2;
                return(false);
            }

            bytesSkipped = bytesToSkip;
            _stream.Seek(bytesToSkip, SeekOrigin.Current);

            return(false);
        }
Ejemplo n.º 5
0
        bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
        {
            //No Stream or Stream cannot seek then we indicate failure
            if (Stream == null || !Stream.CanSeek)
            {
                //Indicate failure
                bytesSkipped = -2;

                return(false);
            }

            bytesSkipped = bytesToSkip;

            Stream.Seek(bytesToSkip, SeekOrigin.Current);

            return(false);
        }
Ejemplo n.º 6
0
        bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
        {
            //No Stream or Stream cannot seek then we indicate failure
            if (Stream == null || !Stream.CanSeek)
            {
                //Indicate failure
                bytesSkipped = -2;

                return(false);
            }

            bytesSkipped = bytesToSkip;

            Stream.Seek(bytesToSkip, SeekOrigin.Current);

            //If data is available immediately set bytesSkipped to the number of of bytes skipped and return true.
            return(true);
        }
Ejemplo n.º 7
0
        bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
        {
            //We don't need the callback, as it's an unmanaged resource we should dispose it (could wrap it in a using statement).
            callback.Dispose();

            //No Stream or Stream cannot seek then we indicate failure
            if (Stream == null || !Stream.CanSeek)
            {
                //Indicate failure
                bytesSkipped = -2;

                return(false);
            }

            bytesSkipped = bytesToSkip;

            Stream.Seek(bytesToSkip, SeekOrigin.Current);

            //If data is available immediately set bytesSkipped to the number of of bytes skipped and return true.
            return(true);
        }
Ejemplo n.º 8
0
 bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     bytesSkipped = -1;
     return(false);
 }
Ejemplo n.º 9
0
 bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
 bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     //Should never be called
     throw new NotImplementedException("This method should never be called");
 }
Ejemplo n.º 11
0
 public bool Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 12
0
 bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     return(ResourceHandler.Skip(bytesToSkip, out bytesSkipped, callback));
 }
Ejemplo n.º 13
0
 public bool Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     bytesSkipped = 0;
     return(true);
 }
Ejemplo n.º 14
0
 bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback)
 {
     bytesSkipped = -2; // ERR_FAILED
     callback.Dispose();
     return(false);
 }