示例#1
0
 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>());
 }
示例#2
0
 public static int Index <T>(this Generic.IEnumerator <T> me, params T[] needles)
     where T : IEquatable <T>
 {
     return(me.Index(element => needles.Contains(element)));
 }
示例#3
0
 public static Generic.IEnumerator <byte> Encode(this Generic.IEnumerator <char> me)
 {
     return(me.Encode(Encoding.Utf8));
 }
示例#4
0
 public Tasks.Task <bool> Write(Generic.IEnumerator <byte> buffer)
 {
     return(this.outDevice?.Write(buffer));
 }
示例#5
0
 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);
         }
     }
 }
示例#6
0
		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();
		}
示例#7
0
 public static async Tasks.Task <bool> WriteLine(this ITextWriter me, Generic.IEnumerator <char> value)
 {
     return(await me.Write(value) && await me.WriteLine());
 }
示例#8
0
 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));
         }
     }
 }
示例#9
0
 internal static ICharacterInDevice Open(Generic.IEnumerator <char> content)
 {
     return(new CharacterInDevice(content));
 }
示例#10
0
 private CharacterInDevice(Generic.IEnumerator <char> value)
 {
     this.backend = value;
     this.Move();
 }
示例#11
0
 public static int Hash <T>(this object me, Generic.IEnumerator <T> others)
 {
     return(unchecked (me.Hash() * 31 + (others.MoveNext() ? others.Current.Hash(others) : 0)));
 }
示例#12
0
文件: Device.cs 项目: Spaxys/Kean
 public Tasks.Task <bool> Write(Generic.IEnumerator <char> buffer)
 {
     return(this.Write(buffer.Encode(this.Encoding)));
 }
示例#13
0
 public static ITextReader From(Generic.IEnumerator <char> content)
 {
     return(TextReader.Open(CharacterInDevice.Open(content)));
 }
示例#14
0
 public static T Next <T>(this Generic.IEnumerator <T> me, T @default = default(T))
 {
     return(me.NotNull() && me.MoveNext() ? me.Current : @default);
 }
示例#15
0
 public async Tasks.Task <bool> Write(Generic.IEnumerator <char> buffer)
 {
     return(this.Opened && await this.write(buffer));
 }
示例#16
0
 public static T[] ToArray <T>(this Generic.IEnumerator <T> me)
 {
     return(me.NotNull() ? me.ToArray(0) : null);
 }
示例#17
0
 public void Prepend(Generic.IEnumerable <char> expect, Generic.IEnumerator <char> prefix, Generic.IEnumerator <char> postfix)
 {
     Assert.Equal(expect.ToArray(), postfix.Prepend(prefix).ToArray());
 }
示例#18
0
 public static Generic.IEnumerator <T> Append <T>(this Generic.IEnumerator <T> me, params T[] other)
 {
     return(me.Append(((Generic.IEnumerable <T>)other).GetEnumerator()));
 }
示例#19
0
文件: TextWriter.cs 项目: Spaxys/Kean
 public NewLineConverter(Generic.IEnumerator <char> backend, params char[] newLine)
 {
     this.backend = backend;
     this.newLine = newLine;
 }
示例#20
0
 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()));
 }
示例#21
0
文件: TextWriter.cs 项目: Spaxys/Kean
 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);
 }
示例#22
0
		public bool Close()
		{
			bool result;
			if (result = this.backend.NotNull() && this.backend.Close())
			{
				this.backend = null;
				this.queue = null;
			}
			return result;
		}
示例#23
0
 public static ICharacterInDevice From(Generic.IEnumerator <char> content)
 {
     return(CharacterInDevice.Open(content));
 }