Пример #1
0
        protected virtual async Task DefineObservers(ReactiveClientContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var consoleObserverFactory = (Expression <Func <IAsyncReactiveQbserver <T> > >)(() => new ConsoleObserver <T>().AsQbserver());
            var consoleObserver        = context.Provider.CreateQbserver <T>(consoleObserverFactory.Body);
            await context.DefineObserverAsync <T>(Platform.Constants.Identifiers.Observer.ConsoleObserver.Uri, consoleObserver, null, CancellationToken.None).ConfigureAwait(false);

            await context.DefineObserverAsync <string, T>(Platform.Constants.Identifiers.Observer.ConsoleObserverParam.Uri, prefix => new ConsoleObserver <T>(prefix).AsQbserver(), null, CancellationToken.None).ConfigureAwait(false);

            var traceObserverFactory = (Expression <Func <IAsyncReactiveQbserver <T> > >)(() => new TraceObserver <T>().AsQbserver());
            var traceObserver        = context.Provider.CreateQbserver <T>(traceObserverFactory.Body);
            await context.DefineObserverAsync <T>(Platform.Constants.Identifiers.Observer.TraceObserver.Uri, traceObserver, null, CancellationToken.None).ConfigureAwait(false);

            await context.DefineObserverAsync <string, T>(Platform.Constants.Identifiers.Observer.TraceObserverParam.Uri, prefix => new TraceObserver <T>(prefix).AsQbserver(), null, CancellationToken.None).ConfigureAwait(false);

            await context.DefineObserverAsync <Uri, T>(Platform.Constants.Identifiers.Observer.FireHose.Uri, uri => new FirehoseObserver <T>(uri).AsQbserver(), null, CancellationToken.None).ConfigureAwait(false);

            await context.DefineObserverAsync <string, T>(Platform.Constants.Identifiers.Observer.Throughput.Uri, s => new ThroughputObserver <T>(s).AsQbserver(), null, CancellationToken.None).ConfigureAwait(false);

            var nopObserverFactory = (Expression <Func <IAsyncReactiveQbserver <T> > >)(() => NopObserver <T> .Instance.AsQbserver());
            var nopObserver        = context.Provider.CreateQbserver <T>(nopObserverFactory.Body);
            await context.DefineObserverAsync <T>(new Uri(Client.Constants.Observer.Nop), nopObserver, null, CancellationToken.None).ConfigureAwait(false);
        }
Пример #2
0
        protected override async Task DefineObservers(ReactiveClientContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            await base.DefineObservers(context).ConfigureAwait(false);

            await context.DefineObserverAsync <Uri, T>(
                Constants.Test.TestObserver.Uri,
                name => new TestObserver <T>(name).AsQbserver(),
                null,
                CancellationToken.None).ConfigureAwait(false);
        }
Пример #3
0
        protected virtual async Task DefineObservers(ReactiveClientContext context)
        {
            var nopObserverFactory = (Expression <Func <IAsyncReactiveQbserver <T> > >)(() => NopObserver <T> .Instance.AsQbserver());
            var nopObserver        = context.Provider.CreateQbserver <T>(nopObserverFactory.Body);

            await context.DefineObserverAsync <HttpVerb, Uri, Tuple <string, string>[], SerializationProtocol, RetryData, T>(
                Reactor.Constants.Identifiers.Observer.Http.Uri,
                (method, endpoint, headers, protocol, retryData) =>
                new HttpObserver <T>(method, endpoint, headers, protocol, retryData).AsQbserver(),
                null,
                CancellationToken.None);

            await context.DefineObserverAsync <HttpData>(
                Reactor.Constants.Identifiers.Observer.Http.Action.Uri,
                context.GetObserver <string, HttpData>(Platform.Constants.Identifiers.Observer.ConsoleObserverParam.Uri)("DoHttp"),
                null,
                CancellationToken.None);

            await context.DefineObserverAsync <string, Uri, Uri, Tuple <string, string>[], RetryData, TimeSpan, T>(
                Reactor.Constants.Identifiers.Observer.Http.Final.Uri,
                (method, onCompleted, onError, headers, retryData, timeout) => nopObserver,
                null,
                CancellationToken.None);

            await context.DefineObserverAsync <HttpPost>(
                Reactor.Constants.Identifiers.Observer.HttpPost.Action.Uri,
                context.GetObserver <string, HttpPost>(Platform.Constants.Identifiers.Observer.ConsoleObserverParam.Uri)("DoHttpPost"),
                null,
                CancellationToken.None);

            await context.DefineObserverAsync <Uri, Uri, Tuple <string, string>[], T>(
                new Uri(Reactor.Constants.Identifiers.Observer.HttpPost.Final.WithHeaders),
                (onError, onCompleted, headers) => nopObserver,
                null,
                CancellationToken.None);

            await context.DefineObserverAsync <Uri, Uri, T>(
                new Uri(Reactor.Constants.Identifiers.Observer.HttpPost.Final.NoHeaders),
                (onError, onCompleted) => nopObserver,
                null,
                CancellationToken.None);
        }