Beispiel #1
0
        public override IAsyncResult BeginWrite(byte [] buffer, int offset, int count,
                                                System.AsyncCallback cback, object state)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }
            else if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "Must be >= 0");
            }
            else if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "Must be >= 0");
            }
            else if (count > buffer.Length - offset)
            {
                throw new ArgumentException("Buffer too small, count/offset wrong");
            }
            else if (!CanWrite)
            {
                throw new NotSupportedException("The stream does not support writing");
            }

            if (!IsAsync)
            {
                return(base.BeginRead(buffer, offset, count, cback, state));
            }

            VfsStreamAsync async = new VfsStreamAsync(handle, buffer, offset, count, cback, state);

            return(async.BeginWrite());
        }
		public override IAsyncResult BeginWrite (byte [] buffer, int offset, int count,
							 System.AsyncCallback cback, object state)
		{
			if (buffer == null)
				throw new ArgumentNullException ("buffer");
			else if (offset < 0)
				throw new ArgumentOutOfRangeException ("offset", "Must be >= 0");
			else if (count < 0)
				throw new ArgumentOutOfRangeException ("count", "Must be >= 0");
			else if (count > buffer.Length - offset)
				throw new ArgumentException ("Buffer too small, count/offset wrong");
			else if (!CanWrite)
				throw new NotSupportedException ("The stream does not support writing");

			if (!IsAsync)
				return base.BeginRead (buffer, offset, count, cback, state);

			VfsStreamAsync async = new VfsStreamAsync (handle, buffer, offset, count, cback, state);
			return async.BeginWrite ();
		}