コード例 #1
0
        void ReleaseDesignerOutlets()
        {
            if (CalloutLayout != null)
            {
                CalloutLayout.Dispose();
                CalloutLayout = null;
            }

            if (ContentLayout != null)
            {
                ContentLayout.Dispose();
                ContentLayout = null;
            }

            if (SenderLabel != null)
            {
                SenderLabel.Dispose();
                SenderLabel = null;
            }

            if (MessageLabel != null)
            {
                MessageLabel.Dispose();
                MessageLabel = null;
            }

            if (DateLabel != null)
            {
                DateLabel.Dispose();
                DateLabel = null;
            }
        }
コード例 #2
0
        public MainPage()
        {
            InitializeComponent();

            MessageLabel.SetBinding(Button.TextProperty, "ChangeText", BindingMode.OneWayToSource);
            MessageButton.SetBinding(Button.CommandProperty, "ButtonCommand");
        }
コード例 #3
0
        void ReleaseDesignerOutlets()
        {
            if (ImageView != null)
            {
                ImageView.Dispose();
                ImageView = null;
            }

            if (MessageLabel != null)
            {
                MessageLabel.Dispose();
                MessageLabel = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (ProfileImageView != null)
            {
                ProfileImageView.Dispose();
                ProfileImageView = null;
            }

            if (Constraint_ImageViewRatio != null)
            {
                Constraint_ImageViewRatio.Dispose();
                Constraint_ImageViewRatio = null;
            }
        }
コード例 #4
0
        private void CreateEmployee_button_Click(object sender, EventArgs e)
        {
            var employeeInfo = new Employee
            {
                FirstName   = Name_textbox.Text,
                LastName    = Surnname_textbox.Text,
                Phone       = Phone_textbox.Text,
                Description = Details_textbox.Text
            };

            ;
            if (!EmployeeValidator.ValidateFirstOrSecondName(employeeInfo.FirstName))
            {
                NameErrorProvider.SetError(Name_textbox, "Name is not correct.");
            }
            if (!EmployeeValidator.ValidateFirstOrSecondName(employeeInfo.LastName))
            {
                SecondNameErrorProvider.SetError(Surnname_textbox, "Second name is not correct.");
            }
            if (!EmployeeValidator.ValidatePhoneNumber(employeeInfo.Phone, true))
            {
                PhoneNumberErrorProvider.SetError(Phone_textbox, $"Phone number is not correct.{Environment.NewLine}It should contain 10 digits.");
            }
            if (EmployeeValidator.IsValidClientInfo(employeeInfo))
            {
                EmployeeHelper.InsertEmployeeInfo(employeeInfo);
                ClearForm();
                MessageLabel.Show();
                MessageLabel.Text = "Client info was successfully saved!";
                //Thread.Sleep(2000);//queeck dummy way))) TODO: change!
                //MessageLabel.Text = string.Empty;
            }
        }
コード例 #5
0
        /// <summary>
        /// The inject.
        /// </summary>
        /// <param name="raw">
        /// The raw.
        /// </param>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <exception cref="ArgumentException">
        /// </exception>
        public void Inject(object raw, MessageLabel label)
        {
            if (label.IsEmpty)
            {
                return;
            }

            var props = raw as IBasicProperties;

            if (props == null)
            {
                throw new ArgumentException(
                          "Expected [{0}] but got [{1}].".FormatEx(
                              typeof(IBasicProperties).Name,
                              raw.GetType().
                              Name));
            }

            if (props.Headers == null)
            {
                props.Headers = new Dictionary <string, object>();
            }

            props.Headers[Headers.MessageLabel] = label.Name;
        }
コード例 #6
0
        void ReleaseDesignerOutlets()
        {
            if (ContentView != null)
            {
                ContentView.Dispose();
                ContentView = null;
            }

            if (ActivityIndicator != null)
            {
                ActivityIndicator.Dispose();
                ActivityIndicator = null;
            }

            if (LoadingView != null)
            {
                LoadingView.Dispose();
                LoadingView = null;
            }

            if (MessageLabel != null)
            {
                MessageLabel.Dispose();
                MessageLabel = null;
            }

            if (ProgressLabel != null)
            {
                ProgressLabel.Dispose();
                ProgressLabel = null;
            }
        }
コード例 #7
0
        void ReleaseDesignerOutlets()
        {
            if (CommunityLabel != null)
            {
                CommunityLabel.Dispose();
                CommunityLabel = null;
            }

            if (DateLabel != null)
            {
                DateLabel.Dispose();
                DateLabel = null;
            }

            if (MessageLabel != null)
            {
                MessageLabel.Dispose();
                MessageLabel = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (UnreadCountLabel != null)
            {
                UnreadCountLabel.Dispose();
                UnreadCountLabel = null;
            }
        }
コード例 #8
0
        /// <summary>
        /// The try resolver for.
        /// </summary>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <returns>
        /// The <see cref="Producer"/>.
        /// </returns>
        private Producer TryResolverFor(MessageLabel label)
        {
            Producer producer;

            this._producers.TryGetValue(label, out producer);
            return(producer);
        }
コード例 #9
0
        public IEnumerable <TestCaseData> GetCases()
        {
            yield return(new TestCaseData(GetCacheConfig(), GetExchange(), GetResponse()).Returns(new CombinedTestResult(ResponseValue))
                         .SetName("not null response should be equal to cached value"));

            var config = GetCacheConfig();

            config[RouteName].Cache.Set(new Message <TestRequest>(MessageLabel.From(RouteName), GetRequest()), GetResponse(), TimeSpan.Zero);
            yield return(new TestCaseData(config, GetExchange(), new TestResponse {
                Value = "NotFromCacheResponse"
            }).Returns(new CombinedTestResult(ResponseValue, "NotFromCacheResponse"))
                         .SetName("cached value should be returned if set"));

            yield return(new TestCaseData(GetCacheConfig(false), GetExchange(), GetResponse()).Returns(new CombinedTestResult(null, ResponseValue))
                         .SetName("cache should be disabled when caching is disabled in configuration"));

            yield return(new TestCaseData(GetCacheConfig(null), GetExchange(), GetResponse()).Returns(new CombinedTestResult(null, ResponseValue))
                         .SetName("cache should be disabled when ttl is not set in configuration"));

            yield return(new TestCaseData(GetCacheConfig(null), new MessageExchange(new Message(MessageLabel.From(RouteName), new TestRequest())), GetResponse()).Returns(new CombinedTestResult(null, ResponseValue))
                         .SetName("cache should not be accessed when emitting non-request message"));

            yield return(new TestCaseData(GetCacheConfig(new AlwaysExpiringCache(), TimeSpan.Zero), GetExchange(), GetResponse()).Returns(new CombinedTestResult(null, ResponseValue))
                         .SetName("value should be requested when not found in cache"));
        }
コード例 #10
0
        public object TestCacheIsSet(IDictionary <string, CacheConfiguration> cacheConfiguration, MessageExchange exchange, TestResponse response)
        {
            // Arrange
            var responseMessage = new Message <TestResponse>(MessageLabel.From(RouteName), response);
            var sendFilter      = new SendingExchangeFilter(
                e =>
            {
                e.In    = responseMessage;
                var tcs = new TaskCompletionSource <bool>();
                tcs.SetResult(true);
                return(tcs.Task);
            });
            var sut = new CachingFilterDecorator(cacheConfiguration);

            // Act
            sut.Process(sendFilter, exchange, new MessageExchangeFilterInvoker(new[] { sendFilter }, new Dictionary <Type, IMessageExchangeFilterDecorator> {
                { sendFilter.GetType(), sut }
            })).Wait();

            // Assert
            var cache  = cacheConfiguration[exchange.Out.Label.Name].Cache;
            var cached = cache.ContainsKey(exchange.Out) ? ((TestResponse)cache[exchange.Out]).Value : null;

            return(new CombinedTestResult(cached, response.Value));
        }
コード例 #11
0
        void ReleaseDesignerOutlets()
        {
            if (ContentView != null)
            {
                ContentView.Dispose();
                ContentView = null;
            }

            if (MessageLabel != null)
            {
                MessageLabel.Dispose();
                MessageLabel = null;
            }

            if (OkButtonLabel != null)
            {
                OkButtonLabel.Dispose();
                OkButtonLabel = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }
        }
コード例 #12
0
        protected MessageLabel createMessageLabel(string str)
        {
            MessageLabel messageLabel = new MessageLabel(str, this.focus ? this.focusColor : this.unFocusColor, this.core.ChatForm.ChatInput);

            this.messages.Add(messageLabel);
            messageLabel.Disposed += msgLabelDisposed;
            return(messageLabel);
        }
コード例 #13
0
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="SenderConfiguration"/>.
        /// </summary>
        /// <param name="label">Метка отправляемых сообщений.</param>
        /// <param name="parentOptions">Настройки отправителя.</param>
        /// <param name="receiverOptions">Настройки получателя (для ответных сообщений).</param>
        public SenderConfiguration(MessageLabel label, SenderOptions parentOptions, ReceiverOptions receiverOptions)
        {
            this.receiverOptions = receiverOptions;
            Requires.Format(MessageLabel.IsValidLabel(label.Name), "label");
            this.Label = label;

            this.Options = (SenderOptions)parentOptions.Derive();
        }
コード例 #14
0
        private static MessageExchange GetExchange(string routeName = null)
        {
            var outMessage = new Message <TestRequest>(MessageLabel.From(!string.IsNullOrEmpty(routeName) ? routeName : RouteName), GetRequest());

            var exchange = new MessageExchange(outMessage, typeof(TestResponse));

            return(exchange);
        }
コード例 #15
0
 private void ClearForm_button_Click(object sender, EventArgs e)
 {
     ClearForm();
     NameErrorProvider.Clear();
     SecondNameErrorProvider.Clear();
     PhoneNumberErrorProvider.Clear();
     MessageLabel.Hide();
 }
コード例 #16
0
        /// <summary>
        /// Sends message using request-reply pattern.
        /// Copies all allowed message headers. And generates new <see cref="Headers.CorrelationId"/> header.
        /// <seealso ref="https://github.com/SDVentures/Contour#contour-message-headers"/>.
        /// </summary>
        /// <param name="label">Message label.</param>
        /// <param name="payload">Message payload.</param>
        /// <param name="options">Request options.</param>
        /// <typeparam name="T">Type of response.</typeparam>
        /// <returns>Request processing task.</returns>
        public Task <T> Request <T>(MessageLabel label, object payload, RequestOptions options) where T : class
        {
            var headers = this.ApplyOptions(options);

            headers[Headers.CorrelationId] = Guid.NewGuid().ToString("n");

            return(this.Request <T>(label, payload, headers));
        }
コード例 #17
0
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="SenderConfiguration"/>.
        /// </summary>
        /// <param name="label">Метка отправляемых сообщений.</param>
        /// <param name="parentOptions">Настройки отправителя.</param>
        /// <param name="receiverOptions">Настройки получателя (для ответных сообщений).</param>
        public SenderConfiguration(MessageLabel label, SenderOptions parentOptions, ReceiverOptions receiverOptions)
        {
            this.receiverOptions = receiverOptions;
            Requires.Format(MessageLabel.IsValidLabel(label.Name), "label");
            this.Label = label;

            this.Options = (SenderOptions)parentOptions.Derive();
        }
コード例 #18
0
ファイル: MainPage.xaml.cs プロジェクト: LewisJones30/SOFT262
        public MainPage()
        {
            InitializeComponent();

            MessageLabel.BindingContext = ToggleSwitch;
            MessageLabel.SetBinding(Label.IsVisibleProperty, "IsToggled", BindingMode.TwoWay);
            MessageButton.BindingContext = ToggleSwitch;
            MessageButton.SetBinding(Button.IsEnabledProperty, "IsToggled", BindingMode.TwoWay);
        }
コード例 #19
0
ファイル: TopologyBuilder.cs プロジェクト: mzabolotko/Contour
        /// <summary>
        /// Создает временную конечную точку для получения сообщений.
        /// </summary>
        /// <param name="endpoint">Конечная точка шины сообщений для который создается подписка.</param>
        /// <param name="label">Метка сообщений, на которые ожидается получение ответа.</param>
        /// <returns>
        /// Конечная точка подписки для получения сообщений.
        /// </returns>
        public ISubscriptionEndpoint BuildTempReplyEndpoint(IEndpoint endpoint, MessageLabel label)
        {
            var queue = Queue.Named(string.Format("{0}.replies-{1}-{2}", endpoint.Address, label.IsAny ? "any" : label.Name, NameGenerator.GetRandomName(8)))
                .AutoDelete.Exclusive.Instance;

            this.rabbitChannel.Declare(queue);

            return new SubscriptionEndpoint(queue, new StaticRouteResolver(string.Empty, queue.Name));
        }
コード例 #20
0
        /// <summary>
        /// Пересылает сообщение, устанавливая указанную метку.
        /// </summary>
        /// <param name="label">Новая метка, с которой пересылается сообщение.</param>
        /// <param name="payload">Новое содержимое сообщения.</param>
        /// <returns>Задачи пересылки сообщения.</returns>
        public Task Forward(MessageLabel label, object payload)
        {
            var headers = new Dictionary <string, object>(this.Headers);

            headers[ServiceBus.Headers.CorrelationId] = this.CorrelationId;
            headers[ServiceBus.Headers.ReplyRoute]    = this.ReplyRoute;

            return(this.Channel.Bus.Emit(label, payload, headers));
        }
コード例 #21
0
        /// <summary>
        /// Создает временную конечную точку для получения сообщений.
        /// </summary>
        /// <param name="endpoint">Конечная точка шины сообщений для который создается подписка.</param>
        /// <param name="label">Метка сообщений, на которые ожидается получение ответа.</param>
        /// <returns>
        /// Конечная точка подписки для получения сообщений.
        /// </returns>
        public ISubscriptionEndpoint BuildTempReplyEndpoint(IEndpoint endpoint, MessageLabel label)
        {
            var queue = Queue.Named(string.Format("{0}.replies-{1}-{2}", endpoint.Address, label.IsAny ? "any" : label.Name, NameGenerator.GetRandomName(8)))
                        .AutoDelete.Exclusive.Instance;

            this.rabbitChannel.Declare(queue);

            return(new SubscriptionEndpoint(queue, new StaticRouteResolver(string.Empty, queue.Name)));
        }
コード例 #22
0
        /// <summary>
        /// Registers a new consumer of messages with label <paramref name="label"/>
        /// </summary>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <param name="consumer">
        /// The consumer.
        /// </param>
        /// <typeparam name="T">
        /// The message payload type
        /// </typeparam>
        public override void RegisterConsumer <T>(MessageLabel label, IConsumerOf <T> consumer)
        {
            this.logger.Trace($"Registering consumer of [{typeof(T).Name}] in receiver of label [{label}]");

            foreach (var listener in this.listeners)
            {
                listener.RegisterConsumer(label, consumer, this.Configuration.Validator);
            }
        }
コード例 #23
0
        /// <summary>
        /// Устанавливает псевдоним для метки сообщения.
        /// </summary>
        /// <param name="alias">Псевдоним метки сообщения.</param>
        /// <returns>Конфигурация отправителя.</returns>
        public ISenderConfigurator WithAlias(string alias)
        {
            string tempAlias = MessageLabel.AliasPrefix + alias;

            Requires.Format(MessageLabel.IsValidAlias(tempAlias), "alias");

            this.Alias = tempAlias;

            return(this);
        }
コード例 #24
0
        protected void ProcessButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (InviteCommentsRadioButton.Checked)
                {
                    WorkflowManager.InviteUserToWorkflow(AssetWorkflowUser, InviteCommentsTextBox.Text, ResponseTextArea.Text);
                    MessageLabel.SetSuccessMessage("Invitation sent successfully");
                }
                else
                {
                    AssetWorkflowUserStatus assetWorkflowUserStatus;

                    if (ApproveRadioButton.Checked)
                    {
                        assetWorkflowUserStatus = AssetWorkflowUserStatus.Approved;
                    }
                    else if (RejectRadioButton.Checked)
                    {
                        assetWorkflowUserStatus = AssetWorkflowUserStatus.Rejected;
                    }
                    else
                    {
                        assetWorkflowUserStatus = AssetWorkflowUserStatus.Pending;
                    }

                    AssetWorkflowUser.AssetWorkflowUserStatus = assetWorkflowUserStatus;
                    AssetWorkflowUser.Comments   = ResponseTextArea.Text.Trim();
                    AssetWorkflowUser.LastUpdate = DateTime.Now;

                    WorkflowManager.SaveWorkflowUserAndAdvance(AssetWorkflowUser);

                    switch (assetWorkflowUserStatus)
                    {
                    case (AssetWorkflowUserStatus.Approved):
                    case (AssetWorkflowUserStatus.Rejected):

                        MessageLabel.SetSuccessMessage("Your comments have been saved.");
                        DisableUI();
                        break;

                    case (AssetWorkflowUserStatus.Pending):

                        MessageLabel.SetSuccessMessage("Comments saved. Please approve or reject this asset to advance the workflow.");
                        break;
                    }
                }

                AssetWorkflowLog.Bind(AssetWorkflow.Asset);
            }
            catch (BaseException bex)
            {
                MessageLabel.SetErrorMessage(bex.Message);
            }
        }
コード例 #25
0
ファイル: RabbitDelivery.cs プロジェクト: ehramovich/Contour
        /// <summary>
        /// Пересылает сообщение, устанавливая указанную метку.
        /// </summary>
        /// <param name="label">Новая метка, с которой пересылается сообщение.</param>
        /// <typeparam name="T">Тип получаемого сообщения.</typeparam>
        /// <returns>Задача пересылки сообщения.</returns>
        public IConsumingContext <T> BuildConsumingContext <T>(MessageLabel label = null) where T : class
        {
            Message <T> message = this.UnpackAs <T>();

            if (label != null && !label.IsAny && !label.IsEmpty)
            {
                message = (Message <T>)message.WithLabel(label);
            }

            return(new DefaultConsumingContext <T>(message, this));
        }
コード例 #26
0
ファイル: RabbitDelivery.cs プロジェクト: ehramovich/Contour
        /// <summary>
        /// Пересылает сообщение, устанавливая указанную метку.
        /// </summary>
        /// <param name="label">Новая метка, с которой пересылается сообщение.</param>
        /// <param name="payload">Новое содержимое сообщения.</param>
        /// <returns>Задачи пересылки сообщения.</returns>
        public Task Forward(MessageLabel label, object payload)
        {
            var headers = new Dictionary <string, object>(this.Headers);

            headers[Contour.Headers.CorrelationId] = this.CorrelationId;
            headers[Contour.Headers.ReplyRoute]    = this.ReplyRoute;
            Contour.Headers.ApplyBreadcrumbs(headers, this.Channel.Bus.Endpoint.Address);
            Contour.Headers.ApplyOriginalMessageId(headers);

            return(this.Channel.Bus.Emit(label, payload, headers));
        }
コード例 #27
0
            public void should_produce_empty_label()
            {
                MessageLabel label = MessageLabel.From(string.Empty);

                label.IsEmpty.Should().
                BeTrue();

                label = MessageLabel.From(null);
                label.IsEmpty.Should().
                BeTrue();
            }
コード例 #28
0
ファイル: BusConfiguration.cs プロジェクト: forki/Contour
        /// <summary>
        /// The route.
        /// </summary>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <returns>
        /// The <see cref="ISenderConfigurator"/>.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// Raises an error if a sender for <paramref name="label"/> has already been registered
        /// </exception>
        public ISenderConfigurator Route(MessageLabel label)
        {
            if (this.HasRegisteredProducerFor(label))
            {
                throw new ArgumentException($"Sender for label [{label}] already registered.", nameof(label));
            }

            var configuration = new SenderConfiguration(label, this.SenderDefaults, this.ReceiverDefaults);

            this.senderConfigurations.Add(configuration);
            return(configuration);
        }
コード例 #29
0
ファイル: Producer.cs プロジェクト: forki/Contour
        /// <summary>
        /// Initializes a new instance of the <see cref="Producer"/> class.
        /// </summary>
        /// <param name="endpoint">
        /// The endpoint.
        /// </param>
        /// <param name="connection">
        /// Соединение с шиной сообщений
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(IEndpoint endpoint, IRabbitConnection connection, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.endpoint = endpoint;

            this.connection             = connection;
            this.BrokerUrl              = connection.ConnectionString;
            this.Label                  = label;
            this.RouteResolver          = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            this.logger = LogManager.GetLogger($"{this.GetType().FullName}({this.BrokerUrl}, {this.Label}, {this.GetHashCode()})");
        }
コード例 #30
0
ファイル: RabbitReceiver.cs プロジェクト: Sliborskii/Contour
        /// <summary>
        /// Registers a new consumer of messages with label <paramref name="label"/>
        /// </summary>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <param name="consumer">
        /// The consumer.
        /// </param>
        /// <typeparam name="T">
        /// The message payload type
        /// </typeparam>
        public override void RegisterConsumer <T>(MessageLabel label, IConsumerOf <T> consumer)
        {
            this.logger.Trace($"Registering consumer of [{typeof(T).Name}] in receiver of label [{label}]");

            foreach (var listener in this.listeners)
            {
                listener.RegisterConsumer(label, consumer, this.Configuration.Validator);

                var listenerLabels = string.Join(",", listener.AcceptedLabels);
                this.logger.Trace($"Listener of labels ({listenerLabels}) has registered a consumer of label [{label}]");
            }
        }
コード例 #31
0
        /// <summary>
        /// The on.
        /// </summary>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <returns>
        /// The <see cref="IReceiverConfigurator"/>.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// </exception>
        public IReceiverConfigurator On(MessageLabel label)
        {
            if (this.HasRegisteredConsumerFor(label))
            {
                throw new ArgumentException(string.Format("Receiver for label [{0}] already registered.", label), "label");
            }

            var configuration = new ReceiverConfiguration(label, this.ReceiverDefaults);

            this.receiverConfigurations.Add(configuration);

            return(configuration);
        }
コード例 #32
0
ファイル: MainPage.xaml.cs プロジェクト: LewisJones30/SOFT262
        public MainPage()
        {
            InitializeComponent();

            ToggleSwitch.BindingContext  = DataModel;
            MessageButton.BindingContext = DataModel;
            MessageLabel.BindingContext  = DataModel;

            ToggleSwitch.SetBinding(Switch.IsToggledProperty, "IsTrue", BindingMode.OneWayToSource);
            MessageButton.SetBinding(Button.IsEnabledProperty, "IsTrue", BindingMode.OneWay);
            MessageLabel.SetBinding(Label.IsVisibleProperty, "IsTrue", BindingMode.OneWay);
            MessageLabel.SetBinding(Label.TextProperty, "CurrentSaying", BindingMode.OneWay);
        }
コード例 #33
0
ファイル: Producer.cs プロジェクト: mzabolotko/Contour
        /// <summary>
        /// Инициализирует новый экземпляр класса <see cref="Producer"/>.
        /// </summary>
        /// <param name="bus">
        /// Конечная точка, для которой создается отправитель.
        /// </param>
        /// <param name="label">
        /// Метка сообщения, которая будет использоваться при отправлении сообщений.
        /// </param>
        /// <param name="routeResolver">
        /// Определитель маршрутов, по которым можно отсылать и получать сообщения.
        /// </param>
        /// <param name="confirmationIsRequired">
        /// Если <c>true</c> - тогда отправитель будет ожидать подтверждения о том, что сообщение было сохранено в брокере.
        /// </param>
        public Producer(RabbitBus bus, MessageLabel label, IRouteResolver routeResolver, bool confirmationIsRequired)
        {
            this.Channel = bus.OpenChannel();
            this.Label = label;
            this.RouteResolver = routeResolver;
            this.ConfirmationIsRequired = confirmationIsRequired;

            if (this.ConfirmationIsRequired)
            {
                this.confirmationTracker = new DefaultPublishConfirmationTracker(this.Channel);
                this.Channel.EnablePublishConfirmation();
                this.Channel.OnConfirmation(this.confirmationTracker.HandleConfirmation);
            }

            this.Failed += _ => ((IBusAdvanced)bus).Panic();
        }
コード例 #34
0
        /// <summary>
        /// The inject.
        /// </summary>
        /// <param name="raw">
        /// The raw.
        /// </param>
        /// <param name="label">
        /// The label.
        /// </param>
        /// <exception cref="ArgumentException">
        /// </exception>
        public void Inject(object raw, MessageLabel label)
        {
            if (label.IsEmpty)
            {
                return;
            }

            var props = raw as IBasicProperties;
            if (props == null)
            {
                throw new ArgumentException(
                    "Expected [{0}] but got [{1}].".FormatEx(
                        typeof(IBasicProperties).Name,
                        raw.GetType().
                            Name));
            }

            if (props.Headers == null)
            {
                props.Headers = new Dictionary<string, object>();
            }

            props.Headers[Headers.MessageLabel] = label.Name;
        }
コード例 #35
0
ファイル: WireTap.cs プロジェクト: ehramovich/Contour
 /// <summary>
 /// »нициализирует новый экземпл¤р класса <see cref="WireTap"/>.
 /// </summary>
 /// <param name="messageLabel">ћетка сообщени¤, куда надо перенаправить вход¤щее сообщение.</param>
 public WireTap(MessageLabel messageLabel)
     : base(message => new[] { messageLabel, message.Label })
 {
 }
コード例 #36
0
 /// <summary>
 /// The resolve.
 /// </summary>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <returns>
 /// The <see cref="IRoute"/>.
 /// </returns>
 public IRoute Resolve(IEndpoint endpoint, MessageLabel label)
 {
     return this._resolverFunc(endpoint, label);
 }
コード例 #37
0
ファイル: StaticRouter.cs プロジェクト: mzabolotko/Contour
 /// <summary>
 /// The resolve.
 /// </summary>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <returns>
 /// The <see cref="IRoute"/>.
 /// </returns>
 public IRoute Resolve(IEndpoint endpoint, MessageLabel label)
 {
     return this._route;
 }
コード例 #38
0
 /// <summary>
 /// The resolve for.
 /// </summary>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <returns>
 /// The <see cref="Listener"/>.
 /// </returns>
 public Listener ResolveFor(MessageLabel label)
 {
     return this.listeners.First(l => l.Supports(label));
 }
コード例 #39
0
 /// <summary>
 /// The try resolver for.
 /// </summary>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <returns>
 /// The <see cref="Producer"/>.
 /// </returns>
 private Producer TryResolverFor(MessageLabel label)
 {
     Producer producer;
     this._producers.TryGetValue(label, out producer);
     return producer;
 }
コード例 #40
0
ファイル: Exchange.cs プロジェクト: mzabolotko/Contour
 /// <summary>
 /// The resolve.
 /// </summary>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <returns>
 /// The <see cref="IRoute"/>.
 /// </returns>
 public IRoute Resolve(IEndpoint endpoint, MessageLabel label)
 {
     return new RabbitRoute(this.Name);
 }
コード例 #41
0
ファイル: StaticRouter.cs プロジェクト: mzabolotko/Contour
 /// <summary>
 /// Builds operator instance.
 /// </summary>
 /// <param name="label">Target label.</param>
 public StaticRouter(MessageLabel label)
 {
     this.label = label;
 }
コード例 #42
0
 /// <summary>
 /// The can consume.
 /// </summary>
 /// <param name="label">
 /// The label.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public bool CanConsume(MessageLabel label)
 {
     return this.listeners.Any(l => l.AcceptedLabels.Contains(label));
 }