示例#1
0
文件: ByteDevice.cs 项目: Spaxys/Kean
        public async Tasks.Task <bool> Write(Generic.IEnumerator <byte> buffer)
        {
            bool result = buffer.NotNull();

            if (result)
            {
                int seek = this.peeked.Reset();
                if (seek != 0)
                {
                    await this.Seek(seek);
                }
                try
                {
                    byte[] array = buffer.ToArray();
                    await this.backend.WriteAsync(array, 0, array.Length);

                    if (this.AutoFlush)
                    {
                        await this.Flush();
                    }
                }
                catch (System.Exception)
                {
                    result = false;
                }
            }
            return(result);
        }
示例#2
0
 static T[] ToArray <T>(this Generic.IEnumerator <T> me, int count)
 {
     T[] result;
     if (me.MoveNext())
     {
         var head = me.Current;
         result        = me.ToArray(count + 1);
         result[count] = head;
     }
     else
     {
         result = new T[count];
     }
     return(result);
 }
示例#3
0
 public void Test(char[] expected, Generic.IEnumerator <char> actual)
 {
     Assert.Equal(expected, actual.ToArray());
 }
示例#4
0
 public Builder Prepend(Generic.IEnumerator <char> value)
 {
     this.data.Add(value.ToArray());
     return(this);
 }
示例#5
0
 public static T[] ToArray <T>(this Generic.IEnumerator <T> me)
 {
     return(me.NotNull() ? me.ToArray(0) : null);
 }