Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommitMessageDecorator"/> class.
 /// </summary>
 /// <param name="handler">The handler.</param>
 /// <param name="tracer">The tracer.</param>
 /// <param name="headers">The headers.</param>
 public MessageInterceptorDecorator(IMessageInterceptor handler, ITracer tracer, IStandardHeaders headers)
 {
     _handler    = handler;
     _tracer     = tracer;
     _headers    = headers;
     DisplayName = _handler.DisplayName;
 }
        public MyCustomDuplexSessionChannel(IDuplexSessionChannel innerChannel)
        {
            this.innerChannel = innerChannel;

            this.innerChannel.Closed  += new EventHandler(innerChannel_Closed);
            this.innerChannel.Closing += new EventHandler(innerChannel_Closing);
            this.innerChannel.Faulted += new EventHandler(innerChannel_Faulted);
            this.innerChannel.Opened  += new EventHandler(innerChannel_Opened);
            this.innerChannel.Opening += new EventHandler(innerChannel_Opening);

            this.interceptor = new MessageInterceptor();
        }
        public SearchDialog(IMessageInterceptor messageInterceptor, IProductFetcher productFetcher)
            : base(nameof(SearchDialog), messageInterceptor)
        {
            _productFetcher = productFetcher;

            AddDialog(new TextPrompt(nameof(TextPrompt)));

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                SearchPromptAsync,
                SearchAsync
            }));

            InitialDialogId = nameof(WaterfallDialog);
        }
        public CatalogDialog(
            IMessageInterceptor messageInterceptor,
            IProductFetcher productFetcher,
            SearchDialog searchDialog
            )
            : base(nameof(CatalogDialog), messageInterceptor)
        {
            _productFetcher = productFetcher;

            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                GreetingsMessageAsync
            }));
            AddDialog(searchDialog);

            InitialDialogId = nameof(WaterfallDialog);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageInterceptorDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public MessageInterceptorDecorator(IMetrics metrics,
            IMessageInterceptor handler,
            IConnectionInformation connectionInformation)
        {
            _handler = handler;
            var name = handler.GetType().Name;

            _metricTimerBytes =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.BytesToMessageTimer", Units.Calls);

            _metricTimerMessage =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.MessageToBytesTimer", Units.Calls);

            _metricHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesHistogram", Units.Bytes,
                SamplingTypes.LongTerm);

            _metricHistogramDelta = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesDeltaHistogram", Units.Bytes,
                SamplingTypes.LongTerm);

            _metricHistogramOptOut = metrics.Histogram($"{connectionInformation.QueueName}.{name}.OptOutOfGraphHistogram",
                Units.Bytes, SamplingTypes.LongTerm);
        }
        public ViewCartDialog(
            IMessageInterceptor messageInterceptor,
            ICartBuilderFactory cartBuilderFactory,
            IOrderModule orderModule,
            ConversationState conversationState
            )
            : base(nameof(ViewCartDialog), messageInterceptor)
        {
            _cartBuilderFactory = cartBuilderFactory;
            _conversationState  = conversationState;
            _orderModule        = orderModule;

            AddDialog(new ChoicePrompt(nameof(ChoicePrompt)));
            AddDialog(new WaterfallDialog(nameof(WaterfallDialog), new WaterfallStep[]
            {
                ViewCartAsync,
                CreateOrderPromptAsync,
                CreateOrderOrBack
            }));

            InitialDialogId = nameof(WaterfallDialog);
        }
Пример #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageInterceptorDecorator" /> class.
        /// </summary>
        /// <param name="metrics">The metrics factory.</param>
        /// <param name="handler">The handler.</param>
        /// <param name="connectionInformation">The connection information.</param>
        public MessageInterceptorDecorator(IMetrics metrics,
                                           IMessageInterceptor handler,
                                           IConnectionInformation connectionInformation)
        {
            _handler = handler;
            var name = handler.GetType().Name;

            _metricTimerBytes =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.BytesToMessageTimer", Units.Calls);

            _metricTimerMessage =
                metrics.Timer($"{connectionInformation.QueueName}.{name}.MessageToBytesTimer", Units.Calls);

            _metricHistogram = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesHistogram", Units.Bytes,
                                                 SamplingTypes.LongTerm);

            _metricHistogramDelta = metrics.Histogram($"{connectionInformation.QueueName}.{name}.MessageToBytesDeltaHistogram", Units.Bytes,
                                                      SamplingTypes.LongTerm);

            _metricHistogramOptOut = metrics.Histogram($"{connectionInformation.QueueName}.{name}.OptOutOfGraphHistogram",
                                                       Units.Bytes, SamplingTypes.LongTerm);
        }
Пример #8
0
        public void Initialize()
        {
            try
            {
                string assemblyPath    = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                string interceptorPath = Path.Combine(assemblyPath, "Interceptor");

                if (!Directory.Exists(interceptorPath))
                {
                    Directory.CreateDirectory(interceptorPath);
                }

                DirectoryInfo directoryInfo = new DirectoryInfo(interceptorPath);

                FileInfo[] files = directoryInfo.GetFiles("*.dll");

                for (int i = 0; i < files.Length; i++)
                {
                    Assembly assembly = Assembly.LoadFrom(files[i].FullName);
                    Type[]   classes  = assembly.GetTypes();
                    for (int j = 0; j < classes.Length; j++)
                    {
                        Type interceptorInterface = classes[j].GetInterface("IMessageInterceptor", true);
                        if (interceptorInterface != null)
                        {
                            IMessageInterceptor messageInterceptor = Activator.CreateInstance(classes[j]) as IMessageInterceptor;
                            _messageInterceptorList.Add(messageInterceptor);
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show("Exception: Initialize MessageInterceptor");
            }
        }
Пример #9
0
 public void RegisterMessageInterceptor(IMessageInterceptor interceptor)
 {
     _interceptor = interceptor;
 }
 protected InterceptorExtendedBaseDialog(string dialogId, IMessageInterceptor messageInterceptor)
     : base(dialogId)
 {
     _messageInterceptor = messageInterceptor;
 }
 public NServiceBusServiceBus(IBus bus, IMessageInterceptor interceptor = null)
 {
     _interceptor = interceptor ?? EmptyMessageInterceptor.Instance;
     _bus = bus;
 }