aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-02-21 21:30:45 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-02-21 21:30:45 +0200
commitf991f37a95a854e9b2aada52982d83ddaa0ca1b0 (patch)
tree02ea1f3b73cd5a500023a5d0daa905fc6978112a /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update
parent956f9ea033553136ebf199fff30f288dc26fbeb0 (diff)
downloadTango-f991f37a95a854e9b2aada52982d83ddaa0ca1b0.tar.gz
Tango-f991f37a95a854e9b2aada52982d83ddaa0ca1b0.zip
Working on macine studio update center..
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs
new file mode 100644
index 000000000..83fbdf7ea
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.MachineStudio.Common.Update
+{
+ /// <summary>
+ /// Represents a FileStream Wrapper dedicated for delivering Read/Write progress callbacks.
+ /// </summary>
+ /// <seealso cref="System.IO.FileStream" />
+ public class FileStreamWrapper : FileStream
+ {
+ private Action<long> _callback;
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="FileStreamWrapper"/> class.
+ /// </summary>
+ /// <param name="fileName">Name of the file.</param>
+ /// <param name="mode">The mode.</param>
+ /// <param name="callback">The callback.</param>
+ public FileStreamWrapper(String fileName, FileMode mode, Action<long> callback) : base(fileName, mode)
+ {
+ _callback = callback;
+ }
+
+ /// <summary>
+ /// Writes a block of bytes to the file stream.
+ /// </summary>
+ /// <param name="array">The buffer containing data to write to the stream.</param>
+ /// <param name="offset">The zero-based byte offset in <paramref name="array" /> from which to begin copying bytes to the stream.</param>
+ /// <param name="count">The maximum number of bytes to write.</param>
+ public override void Write(byte[] array, int offset, int count)
+ {
+ _callback?.Invoke(Length);
+ base.Write(array, offset, count);
+ }
+
+ /// <summary>
+ /// Reads a block of bytes from the stream and writes the data in a given buffer.
+ /// </summary>
+ /// <param name="array">When this method returns, contains the specified byte array with the values between <paramref name="offset" /> and (<paramref name="offset" /> + <paramref name="count" /> - 1<paramref name=")" /> replaced by the bytes read from the current source.</param>
+ /// <param name="offset">The byte offset in <paramref name="array" /> at which the read bytes will be placed.</param>
+ /// <param name="count">The maximum number of bytes to read.</param>
+ /// <returns>
+ /// The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached.
+ /// </returns>
+ public override int Read(byte[] array, int offset, int count)
+ {
+ _callback?.Invoke(Position);
+ return base.Read(array, offset, count);
+ }
+ }
+}