コード例 #1
0
        /// <summary>
        /// This is simple Implementation That will Holds Implementation that will instantiate publisher and subscriber for sending
        /// messages
        /// </summary>
        /// <param name="errorHandler">Error Log Action Handler Expect to be log</param>
        /// <param name="messageFormatter">An Implementation That Hold Massage Data Implementation</param>
        public void SendMessage(Action <String> errorHandler,
                                IMessageFormatter messageFormatter)
        {
            // Instantiate A Publisher
            if (MessagingPublisher == null)
            {
                MessagingPublisher = new MessagingPublisher();
            }

            // Instantiate A Subscriber
            if (MessagingSubscriber == null)
            {
                MessagingSubscriber = new MessagingSubscriber(MessagingPublisher);
            }

            if (MessagingSubscriber.Publisher == null)
            {
                errorHandler(ExceptionCode.SimpleMessaging_NullExceptionThrownForPublisherOverSubscriber);
            }
            else
            {
                MessagingSubscriber.Publisher.DataPublisher += PublisherOnDataPublisher;
                MessagingPublisher.TransformAndPublishData(errorHandler, messageFormatter.MassageData());
            }
        }
コード例 #2
0
        public OrderViewModel(IOrderValidationService validator,
                              ICurrentUserService userCache,
                              IOrderService orderService,
                              IToastService toast,
                              IPageFactory pageFactory,
                              MainThreadNavigator nav,
                              IMessagingSubscriber topicSubscriber,
                              ILogger <OrderViewModel> logger,
                              string deviceType,
                              AlertUtility alertUtility,
                              Action <BaseNavPageType> baseNavigationAction,
                              ICache <Models.Order> orderCache)
        {
            _orderValidator       = validator;
            _userService          = userCache;
            _toast                = toast;
            _nav                  = nav;
            _orderService         = orderService;
            _pageFactory          = pageFactory;
            _orderCache           = orderCache;
            _alertUtility         = alertUtility;
            _topicSubscriber      = topicSubscriber;
            _baseNavigationAction = baseNavigationAction;
            _deviceType           = deviceType;
            _logger               = logger;

            PurchaseOptionsCommand = new Command(async() =>
            {
                var val = await _orderValidator.ValidateOrderRequest(_userService.GetLoggedInAccount());
                if (SubscriptionUtility.SubscriptionActive(val.Subscription))
                {
                    _nav.Push(_pageFactory.GetPage(PageType.SingleReportPurchase, val));
                }
                else
                {
                    _nav.Push(_pageFactory.GetPage(PageType.PurchaseOptions, val));
                }
            });
            OptionsInfoCommand = new Command(async() => await alertUtility.Display("Roof Option Selection",
                                                                                   $"Selecting a roof option allows Fair Squares to determine what roofs you would like measured at the submitted address.{Environment.NewLine}" +
                                                                                   $"{Environment.NewLine}Primary Only- Fair Squares will measure the primary structure, including attached garage.{Environment.NewLine}" +
                                                                                   $"Detached Garage- Fair Squares will also measure the detached garage on the property.{Environment.NewLine}" +
                                                                                   $"Shed/Barn- Fair Squares will also measure a shed or barn on the property.{Environment.NewLine}" +
                                                                                   $"{Environment.NewLine}NOTE: Fair Squares only supports measuring one primary structure per report (with a detached garage or shed/barn if needed).",
                                                                                   "Ok"));
            ErrorMessageRowHeight = 0;
            SelectedOptionIndex   = -1;
            SelectedStateIndex    = -1;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            SetVisualStateForValidation();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }