示例#1
0
 public static AwaitableWrapper WriteAsyncR(this IMyStream myStream, BytesSegment bs)
 {
     if (myStream is IMyStreamWriteR myStreamReuse)
     {
         return(myStreamReuse.WriteAsyncR(bs));
     }
     return(new AwaitableWrapper(myStream.WriteAsync(bs)));
 }
示例#2
0
 public static void Write(this IMyStream myStream, byte[] buf, int offset, int count)
 {
     if (myStream is IMyStreamSync sync)
     {
         sync.Write(new BytesSegment(buf, offset, count));
     }
     else
     {
         myStream.WriteAsync(buf, offset, count).RunSync();
     }
 }
示例#3
0
 public static AwaitableWrapper WriteMultipleAsyncR(this IMyStream myStream, BytesView bv)
 {
     if (myStream is IMyStreamMultiBuffer bvs)
     {
         return(bvs.WriteMultipleAsyncR(bv));
     }
     else
     {
         return(new AwaitableWrapper(NaiveUtils.RunAsyncTask(async() => {
             foreach (var item in bv)
             {
                 if (item.len > 0)
                 {
                     await myStream.WriteAsync(new BytesSegment(item));
                 }
             }
         })));
     }
 }
示例#4
0
 public static Task WriteAsync(this IMyStream myStream, byte[] buf, int offset, int count)
 {
     return(myStream.WriteAsync(new BytesSegment(buf, offset, count)));
 }