Exemple #1
0
 public static async Task WriteAsync(this IFlexibleOutputStream flex, params object[] values)
 {
     foreach (object value in values)
     {
         //Log.Debug ("FlexibleStream.WriteAsync: ", value);
         await flex.WriteAsync(value.ToString()).ConfigureAwait(false);
     }
 }
Exemple #2
0
        public static async Task Eat(this IFlexibleOutputStream flex, StreamReader reader)
        {
            string line;

            while ((line = await reader.ReadLineAsync()) != null)
            {
                Log.Debug("received: ", line);
                await flex.WriteLineAsync(line);
            }
        }
Exemple #3
0
        public static ReadLineHandler ToReadLineCallback(this IFlexibleOutputStream flex)
        {
            return(async(line) => {
                if (line.SpecialCommand == SpecialCommands.CloseStream)
                {
                    Log.Debug("try close!");
                    await flex.TryClose();
                }
                else
                {
                    Log.Debug("eat: ", line);
                    await flex.WriteLineAsync(line.Line).ConfigureAwait(false);

                    Log.Debug("eaten: ", line);
                }
            });
        }
Exemple #4
0
 public void PipeTo(IFlexibleOutputStream target)
 {
     // set the write handler
     OnWrite = target.WriteAsync;
     OnClose = target.TryClose;
 }
Exemple #5
0
 public InternalTextWriter(IFlexibleOutputStream flexi)
 {
     this.flexi = flexi;
 }
Exemple #6
0
        /*public static async Task Eat (, IReadLine readLine, CancellationToken cancelToken)
         * {
         *      readLine.CancelToken = cancelToken;
         *      while (readLine.IsOpen && !cancelToken.IsCancellationRequested) {
         *
         *              if (await readLine.TryReadLineAsync ().ConfigureAwait (false)) {
         *              }
         *      }
         *
         *      readLine.CancelToken = CancellationToken.None;
         * }*/


        public static TextWriter ToTextWriter(this IFlexibleOutputStream flex)
        {
            return(new InternalTextWriter(flex));
        }