Register() публичный Метод

public Register ( Func elementFactory ) : ChainFactory
elementFactory Func
Результат ChainFactory
Пример #1
0
        public async Task Do()
        {
            var messages = new ConcurrentQueue<TransportMessage>();
            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());

            var countdown = new AsyncCountdownEvent(3);

            var chainFactory = new ChainFactory();
            chainFactory.Register(() => new LogElement(countdown));
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayInUsing());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new DelayInUsing());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new ThrowException());

            var pushMessages = new PushMessages(messages, maxConcurrency: 1);

            await pushMessages.StartAsync(tm => Connector(chainFactory, tm));

            await Task.Delay(2000);

            await pushMessages.StopAsync();
        }
Пример #2
0
        public async Task Do()
        {
            var messages = new ConcurrentQueue <TransportMessage>();

            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());
            messages.Enqueue(new TransportMessage());

            var countdown = new AsyncCountdownEvent(3);

            var chainFactory = new ChainFactory();

            chainFactory.Register(() => new LogElement(countdown));
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayInUsing());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new DelayInUsing());
            chainFactory.Register(() => new DelayBefore());
            chainFactory.Register(() => new DelayAfter());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new PassThrough());
            chainFactory.Register(() => new ThrowException());

            var pushMessages = new PushMessages(messages, maxConcurrency: 1);

            await pushMessages.StartAsync(tm => Connector(chainFactory, tm));

            await Task.Delay(2000);

            await pushMessages.StopAsync();
        }