public static Generic.IEnumerator <T> Create <T>(Generic.IEnumerator <T> enumerator) { return(enumerator.NotNull() ? Enumerator.Create(() => enumerator.Next(), enumerator.Reset, enumerator.Dispose) : Enumerator.Empty <T>()); }
public static int Index <T>(this Generic.IEnumerator <T> me, params T[] needles) where T : IEquatable <T> { return(me.Index(element => needles.Contains(element))); }
public static Generic.IEnumerator <byte> Encode(this Generic.IEnumerator <char> me) { return(me.Encode(Encoding.Utf8)); }
public Tasks.Task <bool> Write(Generic.IEnumerator <byte> buffer) { return(this.outDevice?.Write(buffer)); }
public static Generic.IEnumerator <T> Append <T>(this Generic.IEnumerator <T> me, Generic.IEnumerator <T> other) { if (me.NotNull()) { while (me.MoveNext()) { yield return(me.Current); } } if (other.NotNull()) { while (other.MoveNext()) { yield return(other.Current); } } }
public Decoder(IByteInDevice backend, System.Text.Encoding encoding) { this.backend = backend; this.encoding = encoding; this.queue = this.backend.AsEnumerable().Decode(this.encoding).Cast(c => (char?)c).GetEnumerator(); }
public static async Tasks.Task <bool> WriteLine(this ITextWriter me, Generic.IEnumerator <char> value) { return(await me.Write(value) && await me.WriteLine()); }
public static Generic.IEnumerator <TResult> Zip <TLeft, TRight, TResult>(this Generic.IEnumerator <TLeft> me, Generic.IEnumerator <TRight> other, Func <TLeft, TRight, TResult> combine) { if (me.NotNull() && other.NotNull() && combine.NotNull()) { while (me.MoveNext() && other.MoveNext()) { yield return(combine(me.Current, other.Current)); } } }
internal static ICharacterInDevice Open(Generic.IEnumerator <char> content) { return(new CharacterInDevice(content)); }
private CharacterInDevice(Generic.IEnumerator <char> value) { this.backend = value; this.Move(); }
public static int Hash <T>(this object me, Generic.IEnumerator <T> others) { return(unchecked (me.Hash() * 31 + (others.MoveNext() ? others.Current.Hash(others) : 0))); }
public Tasks.Task <bool> Write(Generic.IEnumerator <char> buffer) { return(this.Write(buffer.Encode(this.Encoding))); }
public static ITextReader From(Generic.IEnumerator <char> content) { return(TextReader.Open(CharacterInDevice.Open(content))); }
public static T Next <T>(this Generic.IEnumerator <T> me, T @default = default(T)) { return(me.NotNull() && me.MoveNext() ? me.Current : @default); }
public async Tasks.Task <bool> Write(Generic.IEnumerator <char> buffer) { return(this.Opened && await this.write(buffer)); }
public static T[] ToArray <T>(this Generic.IEnumerator <T> me) { return(me.NotNull() ? me.ToArray(0) : null); }
public void Prepend(Generic.IEnumerable <char> expect, Generic.IEnumerator <char> prefix, Generic.IEnumerator <char> postfix) { Assert.Equal(expect.ToArray(), postfix.Prepend(prefix).ToArray()); }
public static Generic.IEnumerator <T> Append <T>(this Generic.IEnumerator <T> me, params T[] other) { return(me.Append(((Generic.IEnumerable <T>)other).GetEnumerator())); }
public NewLineConverter(Generic.IEnumerator <char> backend, params char[] newLine) { this.backend = backend; this.newLine = newLine; }
public static bool SameOrEquals <T>(this Generic.IEnumerator <T> me, Generic.IEnumerator <T> other) { return(me.IsNull() && other.IsNull() || me.NotNull() && other.NotNull() && (me.MoveNext() ? other.MoveNext() && me.Current.SameOrEquals(other.Current) && me.SameOrEquals(other) : !other.MoveNext())); }
public async Tasks.Task <bool> Write(Generic.IEnumerator <char> buffer) { this.buffer = this.buffer.Append(new NewLineConverter(buffer, this.NewLine)); return((!this.AutoFlush || await this.Flush()) && this.Writable); }
public bool Close() { bool result; if (result = this.backend.NotNull() && this.backend.Close()) { this.backend = null; this.queue = null; } return result; }
public static ICharacterInDevice From(Generic.IEnumerator <char> content) { return(CharacterInDevice.Open(content)); }