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); }
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); }
public void Test(char[] expected, Generic.IEnumerator <char> actual) { Assert.Equal(expected, actual.ToArray()); }
public Builder Prepend(Generic.IEnumerator <char> value) { this.data.Add(value.ToArray()); return(this); }
public static T[] ToArray <T>(this Generic.IEnumerator <T> me) { return(me.NotNull() ? me.ToArray(0) : null); }