Exemple #1
0
        public void Run()
        {
            var request = CreateRequest();

            if (OnWrite != null)
            {
                OnWrite.Invoke(request);
            }
            else
            {
                OnWriteAsync?.Invoke(request, CancellationToken.None).GetAwaiter().GetResult();
            }

            using (var response = (HttpWebResponse)request.GetResponse()) {
                if (OnRead != null)
                {
                    OnRead?.Invoke(response);
                }
                else
                {
                    OnReadAsync?.Invoke(response, CancellationToken.None).GetAwaiter().GetResult();
                }
            }
        }
Exemple #2
0
        public async Task RunAsync()
        {
            var request = CreateRequest();

            if (OnWriteAsync != null)
            {
                await OnWriteAsync.Invoke(request);
            }
            else if (OnWrite != null)
            {
                OnWrite.Invoke(request);
            }

            using (var response = (HttpWebResponse)await request.GetResponseAsync()) {
                if (OnReadAsync != null)
                {
                    await OnReadAsync.Invoke(response);
                }
                else if (OnRead != null)
                {
                    OnRead?.Invoke(response);
                }
            }
        }
Exemple #3
0
 public override void Write(string message)
 {
     OnWrite.Invoke(message);
 }
Exemple #4
0
 public void WriteLine(decimal value)
 {
     Console.Print(value, ref this.output); OnWrite?.Invoke(this, new EventArgs());
 }
Exemple #5
0
 public void WriteLine()
 {
     Console.Print(output: ref this.output); OnWrite?.Invoke(this, new EventArgs());
 }
Exemple #6
0
 public void Write(int value)
 {
     Console.Print(value, ref this.output, end: ""); OnWrite?.Invoke(this, new EventArgs());
 }
Exemple #7
0
 public void Write(string format, params object[] arg)
 {
     Console.Print(string.Format(format, args: arg), ref this.output, end: ""); OnWrite?.Invoke(this, new EventArgs());
 }
Exemple #8
0
 public void Write(string format, object arg0, object arg1, object arg2)
 {
     Console.Print(string.Format(format, arg0, arg1, arg2), ref this.output, end: ""); OnWrite?.Invoke(this, new EventArgs());
 }