CmisSync.Lib.Streams.ProgressStream.Write C# (CSharp) Méthode

Write() public méthode

Write the specified buffer, offset and count.
public Write ( byte buffer, int offset, int count ) : void
buffer byte /// Buffer. ///
offset int /// Offset. ///
count int /// Count. ///
Résultat void
        public override void Write(byte[] buffer, int offset, int count) {
            // for it may be chained before CryptoStream, we should write the content for CryptoStream has calculated the hash of the content
            this.Stream.Write(buffer, offset, count);
            this.position += count;
            this.NotifyPropertyChanged(Utils.NameOf(() => this.Position));
        }
#endregion

Usage Example

 public void ResumeTest() {
     byte[] inputContent = new byte[100];
     long offset = 100;
     using (var stream = new MemoryStream(inputContent)) 
     using (var offsetstream = new OffsetStream(stream, offset)) {
         using (var progress = new ProgressStream(offsetstream)) {
             progress.PropertyChanged += delegate(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
                 var p = sender as ProgressStream;
                 if (e.PropertyName == Utils.NameOf(() => p.Position)) {
                     this.position = (long)p.Position;
                     this.percent = p.Percent.GetValueOrDefault();
                 }
             };
             progress.Seek(0, SeekOrigin.Begin);
             Assert.AreEqual(offset, this.position);
             Assert.AreEqual(50, this.percent);
             progress.Seek(10, SeekOrigin.Current);
             Assert.AreEqual(offset + 10, this.position);
             progress.Seek(0, SeekOrigin.End);
             Assert.AreEqual(100, this.percent);
             Assert.AreEqual(offset + inputContent.Length, this.position);
             progress.Seek(0, SeekOrigin.Begin);
             progress.WriteByte(0);
             Assert.AreEqual(offset + 1, this.position);
             Assert.AreEqual(50.5, this.percent);
             progress.WriteByte(0);
             Assert.AreEqual(offset + 2, this.position);
             Assert.AreEqual(51, this.percent);
             progress.Write(new byte[10], 0, 10);
             Assert.AreEqual(56, this.percent);
         }
     }
 }
All Usage Examples Of CmisSync.Lib.Streams.ProgressStream::Write