public static bool Write(this IBlockOutDevice me, IBlockInDevice source)
		{
			bool result = source.NotNull() && me.NotNull();
			Collection.IVector<byte> data;
			while (result && !source.Empty && (data = source.Read()).NotNull() && data.Count > 0)
				result &= me.Write(data);
			return result;
		}
Esempio n. 2
0
 public static Generic.IEnumerator <Tasks.Task <Collection.IBlock <byte> > > GetEnumerator(this IBlockInDevice device)
 {
     yield return(device.Read());
 }
Esempio n. 3
0
		protected BlockDeviceCombiner(IBlockInDevice inDevice, IBlockOutDevice outDevice)
		{
			this.inDevice = inDevice;
			this.outDevice = outDevice;
		}
Esempio n. 4
0
		public virtual bool Close()
		{
			bool result;
			if (result = this.inDevice.NotNull() && !this.Wrapped)
			{
				this.inDevice.Close();
				this.inDevice = null;
			}
			if (this.outDevice.NotNull() && !this.Wrapped)
			{
				result |= this.outDevice.NotNull();
				this.outDevice.Close();
				this.outDevice = null;
			}
			return result;
		}
Esempio n. 5
0
		protected BlockDeviceCombiner(IBlockInDevice inDevice) :
			this(inDevice, null)
		{
		}
Esempio n. 6
0
		public static IBlockDevice Wrap(IBlockInDevice inDevice, IBlockOutDevice outDevice)
		{
			return inDevice.NotNull() || outDevice.NotNull() ? new BlockDeviceCombiner(inDevice, outDevice) { Wrapped = true } : null;
		}
Esempio n. 7
0
		public static IBlockDevice Wrap(IBlockInDevice inDevice)
		{
			return BlockDeviceCombiner.Wrap(inDevice, null);
		}
Esempio n. 8
0
		public static IBlockDevice Open(IBlockInDevice inDevice, IBlockOutDevice outDevice)
		{
			return inDevice.NotNull() || outDevice.NotNull() ? new BlockDeviceCombiner(inDevice, outDevice) : null;
		}
Esempio n. 9
0
		public static IBlockDevice Open(IBlockInDevice inDevice)
		{
			return BlockDeviceCombiner.Open(inDevice, null);
		}