Пример #1
0
 public TestScreenCloser(Test test, ITestStateManager stateManager, IMessageCreator messageBox, IEditTestController controller)
 {
     _test         = test;
     _stateManager = stateManager;
     _messageBox   = messageBox;
     _controller   = controller;
 }
Пример #2
0
        private static ExceptionMessageModel GetExceptionMessageModel(IException myException)
        {
            IMessageCreator messageCreator = null;

            switch (myException)
            {
            case IValidationException:
                messageCreator = new ValidationMessageCreator();
                break;

            case IBusinessException:
                messageCreator = new BusinessMessageCreator();
                break;

            case IAuthenticationException:
                messageCreator = new AuthenticationMessageCreator();
                break;

            case IDataException:
                messageCreator = new DataMessageCreator();
                break;

            default:
                break;
            }
            return(messageCreator.GetExceptionMessageModel(myException));
        }
Пример #3
0
        public void InterfaceMessageCreation()
        {
            IBus Bus = null;

            #region 4to5InterfaceMessageCreation

            Bus.Publish <MyInterfaceMessage>(o =>
            {
                o.OrderNumber = 1234;
            });

            #endregion

            IMessageCreator messageCreator = null;

            #region 4to5ReflectionInterfaceMessageCreation

            //This type would be derived from some other runtime information
            Type messageType = typeof(MyInterfaceMessage);

            object instance = messageCreator.CreateInstance(messageType);

            //use reflection to set properties on the constructed instance

            Bus.Publish(instance);

            #endregion
        }
Пример #4
0
 public Helper(MockRepository mocks, IBus b, IMessageCreator messageCreator, IEnumerable <Type> types)
 {
     m   = mocks;
     bus = b;
     this.messageCreator = messageCreator;
     messageTypes        = types;
 }
Пример #5
0
 public WeeeEmailServiceBuilder()
 {
     TemplateExecutor = A.Fake <ITemplateExecutor>();
     MessageCreator   = A.Fake <IMessageCreator>();
     Sender           = A.Fake <IWeeeSender>();
     Configuration    = A.Fake <IWeeeEmailConfiguration>();
 }
Пример #6
0
 public XmlMode(ITestStateManager testState, IMessageCreator messageBox, IXmlView view)
     : base(Mode.Xml)
 {
     _testState = testState;
     _messageBox = messageBox;
     _view = view;
 }
Пример #7
0
        static void Main(string[] args)
        {
            FontManager fontManager = new FontManager(
                new string[] { "meiryo UI" },
                minSize: 14,
                maxSize: 14
                );
            IMessageCreator messageCreator = RandomCharactorCreator.makeNumericCreator(minLen_: 3, maxLen_: 7);

            var drawer = new StringDrawer(messageCreator, fontManager);

            /*
             * CharacterRange[] ranges = new CharacterRange[]{new CharacterRange(0, targetString.Length)};
             *
             * format.SetMeasurableCharacterRanges(ranges);
             *
             * Region[] regions = g.MeasureCharacterRanges(targetString, font, new RectangleF(x: 0, y: 0, width:256, height:128), format);
             *
             * foreach (var r in regions)
             * {
             *  g.DrawRectangle(Pens.Blue, Rectangle.Round(r.GetBounds(g)));
             * }
             */
            for (int i = 0; i < 10; i++)
            {
                var bitmap = drawer.drawNext();
                bitmap.Save(String.Format("sample{0}.png", i));
            }
        }
Пример #8
0
 public MessageHandler(INetworkHandler network, IMessageCreator generalMessageCreator,
                       IMessageCreator positiveResponseMessageCreator)
 {
     _network = network;
     _generalMessageCreator          = generalMessageCreator;
     _positiveResponseMessageCreator = positiveResponseMessageCreator;
 }
Пример #9
0
 /// <summary>
 /// Initializes a new instance of the ReloadSchemaCommand class.
 /// </summary>
 public ReloadSchemaCommand(IDataEditorView dataEditor, IDataSetProvider datasetProvider, IMessageCreator messageCreator, IFileService fileService)
 {
     _fileService     = fileService;
     _messageCreator  = messageCreator;
     _datasetProvider = datasetProvider;
     _dataEditor      = dataEditor;
 }
Пример #10
0
 public TestScreenCloser(Test test, ITestStateManager stateManager, IMessageCreator messageBox, IEditTestController controller)
 {
     _test = test;
     _stateManager = stateManager;
     _messageBox = messageBox;
     _controller = controller;
 }
        public static T CreateMessage <T>(this IMessageCreator creator, Action <T> initialize) where T : class, IMessage
        {
            var message = creator.CreateMessage <T>();

            initialize(message);
            return(message);
        }
        public static object CreateMessage(this IMessageCreator creator, Type messageType)
        {
            var concreteType = creator.GetConcreteMessageType(messageType);
            var message      = Activator.CreateInstance(concreteType);

            return(message);
        }
Пример #13
0
 public XmlMode(ITestStateManager testState, IMessageCreator messageBox, IXmlView view)
     : base(Mode.Xml)
 {
     _testState  = testState;
     _messageBox = messageBox;
     _view       = view;
 }
Пример #14
0
 public FakeEntity(IEventStream stream, IBuilder builder, IMessageCreator creator,
                   IRouteResolver resolver)
 {
     (this as INeedStream).Stream             = stream;
     (this as INeedBuilder).Builder           = builder;
     (this as INeedEventFactory).EventFactory = creator;
     (this as INeedRouteResolver).Resolver    = resolver;
 }
Пример #15
0
 public ScreenConductor(IEventAggregator events, IScreenCollection screens, IScreenObjectLocator screenObjectLocator, IMessageCreator messageBox, IShellService shellService, IScreenFactory factory)
 {
     _events              = events;
     _screens             = screens;
     _screenObjectLocator = screenObjectLocator;
     _messageBox          = messageBox;
     _shellService        = shellService;
     _factory             = factory;
 }
Пример #16
0
        internal Saga(T saga, MockRepository mocks, IBus bus, IMessageCreator messageCreator, List <Type> types)
        {
            this.saga = saga;
            helper    = new Helper(mocks, bus, messageCreator, types);

            var headers = bus.OutgoingHeaders;

            LastCall.Repeat.Any().Return(outgoingHeaders);
        }
Пример #17
0
        private Task <HttpResponseMessage> SendHttpMessage(
            IMessageCreator messageCreator,
            string endpointUrl,
            HttpMethod method,
            HttpContent content)
        {
            var message = messageCreator.CreateMessage(method, endpointUrl, content);

            return(_httpClient.SendAsync(message));
        }
Пример #18
0
            //IMessageCreator is available via dependency injection
            void PublishEvent(IMessageCreator messageCreator)
            {
                var eventMessage = messageCreator.CreateInstance <IMyEvent>(message =>
                {
                    message.SomeProperty = "Hello world";
                });


                bus.Publish(eventMessage);
            }
Пример #19
0
 public Logger(IMessageCreator messageCreator,
               IMessagesDequeuer messagesDequeuer,
               ICallingStackFrameGetter callingStackFrameGetter,
               IContainer <Configuration.Configuration> configurationContainer)
 {
     _configurationContainer  = configurationContainer;
     _messageCreator          = messageCreator;
     _callingStackFrameGetter = callingStackFrameGetter;
     _messagesDequeuer        = messagesDequeuer;
 }
Пример #20
0
 public Logger(IMessageCreator messageCreator,
               IMessagesDequeuer messagesDequeuer,
               ICallingStackFrameGetter callingStackFrameGetter,
               IContainer<Configuration.Configuration> configurationContainer)
 {
     _configurationContainer = configurationContainer;
     _messageCreator = messageCreator;
     _callingStackFrameGetter = callingStackFrameGetter;
     _messagesDequeuer = messagesDequeuer;
 }
Пример #21
0
        public MessageProducer(IProducerFactory <TValue> producerFactory, IMessageCreator <TValue> messageCreator, ILogger <MessageProducer <TValue> > logger)
        {
            if (producerFactory is null)
            {
                throw new ArgumentNullException(nameof(producerFactory));
            }

            _messageCreator = messageCreator ?? throw new ArgumentNullException(nameof(messageCreator));
            _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
            _kafkaProducer  = producerFactory.Build();
        }
        private Task <HttpResponseMessage> SendHttpMessage(
            IMessageCreator messageCreator,
            string endpointUrl,
            HttpMethod method,
            HttpContent content,
            Dictionary <string, string> headers)
        {
            HttpRequestMessage message = messageCreator.CreateMessage(method, endpointUrl, content, headers);

            return(_httpClient.SendAsync(message));
        }
 public WeeeEmailService(
     ITemplateExecutor templateExecutor,
     IMessageCreator messageCreator,
     IWeeeSender sender,
     IWeeeEmailConfiguration configuration)
 {
     this.templateExecutor = templateExecutor;
     this.messageCreator = messageCreator;
     this.sender = sender;
     this.configuration = configuration;
 }
Пример #24
0
    public async Task <HttpResponseMessage> SendAsync(IMessageCreator messageCreator, string endpointUrl, HttpMethod method, HttpContent content = null, Dictionary <string, string> headers = null)
    {
        var message = messageCreator.CreateMessage(method, endpointUrl, content);

        _requestBody = await message.Content.ReadAsStringAsync();

        return(new HttpResponseMessage(HttpStatusCode.Accepted)
        {
            Content = new StringContent(_requestBody)
        });
    }
Пример #25
0
 protected void GenerateStubs()
 {
     datasetProvider       = MockRepository.GenerateStub <IDataSetProvider>();
     view                  = MockRepository.GenerateStub <IDataEditorView>();
     messageCreator        = MockRepository.GenerateStub <IMessageCreator>();
     fileDialogCreator     = MockRepository.GenerateStub <IFileDialogCreator>();
     settingsRepositoru    = MockRepository.GenerateStub <IUserSettingsRepository>();
     projectRepository     = MockRepository.GenerateStub <IProjectRepository>();
     applicationController = MockRepository.GenerateStub <IApplicationController>();
     fileService           = MockRepository.GenerateStub <IFileService>();
 }
Пример #26
0
 public WeeeEmailService(
     ITemplateExecutor templateExecutor,
     IMessageCreator messageCreator,
     IWeeeSender sender,
     IWeeeEmailConfiguration configuration)
 {
     this.templateExecutor = templateExecutor;
     this.messageCreator   = messageCreator;
     this.sender           = sender;
     this.configuration    = configuration;
 }
Пример #27
0
        public SpecifiedSizeMessageGenerator(INetworkHandler network, IMessageCreator messageCreator,
                                             double messageGenerateChance, int messageSize)
            : base(network, messageCreator, messageGenerateChance)
        {
            if (messageSize <= 0)
            {
                throw new ArgumentException("messageSize");
            }

            _messageSize = messageSize;
        }
Пример #28
0
        public MessageGenerator(INetworkHandler network, IMessageCreator messageCreator,
                                double messageGenerateChance)
        {
            if (messageGenerateChance > 1.0 || messageGenerateChance < 0.0)
            {
                throw new ArgumentException("messageGenerateChance");
            }

            _messageGenerateChance = messageGenerateChance;
            Network         = network;
            _messageCreator = messageCreator;
        }
        public async Task <HttpResponseMessage> SendAsync(
            IMessageCreator messageCreator,
            string endpointUrl,
            HttpMethod method,
            HttpContent requestContent          = null,
            Dictionary <string, string> headers = null)
        {
            HttpResponseMessage response = null;

            if (_enableResilienceLogic)
            {
                if (_resiliencePolicyProvider == null)
                {
                    throw new ArgumentNullException(
                              nameof(_resiliencePolicyProvider),
                              $"{nameof(_enableResilienceLogic)} is set to true but {nameof(_resiliencePolicyProvider)} is null.");
                }

                if (_resiliencePolicyProvider.Policy == null)
                {
                    throw new ArgumentNullException(
                              nameof(_resiliencePolicyProvider.Policy),
                              $"{nameof(_resiliencePolicyProvider)}'s {nameof(_resiliencePolicyProvider.Policy)} is null.");
                }

                // Use the resilience logic.
                var policyResult = await _resiliencePolicyProvider.Policy.ExecuteAndCaptureAsync(() =>
                {
                    return(SendHttpMessage(messageCreator, endpointUrl, method, requestContent, headers));
                });

                response = policyResult.FinalHandledResult ?? policyResult.Result;
            }
            else
            {
                // Omit using the resilience logic completely.
                response = await SendHttpMessage(messageCreator, endpointUrl, method, requestContent, headers);
            }

            if (response.IsSuccessStatusCode)
            {
                return(response);
            }

            var responseContent = response.Content;

            throw (responseContent != null) ?
                  new ManagementException(response, await response.Content.ReadAsStringAsync()) :
                  new ManagementException(response, "CM API returned server error.");
        }
Пример #30
0
 public InternalLogger(
     IMessageCreator messageCreator,
     ICallingStackFrameGetter callingStackFrameGetter,
     IMessageTextFormatter messageTextFormatter)
 {
     _messageCreator          = messageCreator;
     _callingStackFrameGetter = callingStackFrameGetter;
     _messageTextFormatter    = messageTextFormatter;
     _filePath = string.Format("{0}{1}{2}.{3}.log",
                               Path.GetTempPath(),
                               Environment.NewLine,
                               AppDomain.CurrentDomain.FriendlyName,
                               Process.GetCurrentProcess().Id);
 }
            //IMessageCreator is available via dependency injection
            async Task PublishEvent(IMessageCreator messageCreator)
            {
                var eventMessage = messageCreator.CreateInstance <IMyEvent>(message =>
                {
                    message.SomeProperty = "Hello world";
                });


                await messageSession.Publish(eventMessage);

                //or if on a message handler

                await context.Publish(eventMessage);
            }
Пример #32
0
 public BackgroundWorker(IMessageExchanger messageExchanger, IMessageGenerator messageGenerator,
                         IComponentDrawer networkDrawer, IMessageCreator messageCreator,
                         IMessageRegistrator messageRegistrator, IMessageViewUpdater messageViewUpdated,
                         int updatePeriod)
 {
     _messageExchanger   = messageExchanger;
     _messageGenerator   = messageGenerator;
     _networkDrawer      = networkDrawer;
     _messageCreator     = messageCreator;
     _messageRegistrator = messageRegistrator;
     _updatePeriod       = updatePeriod;
     _messageViewUpdated = messageViewUpdated;
     _locker             = new Mutex();
 }
Пример #33
0
 public InternalLogger(
     IMessageCreator messageCreator, 
     ICallingStackFrameGetter callingStackFrameGetter, 
     IMessageTextFormatter messageTextFormatter)
 {
     _messageCreator = messageCreator;
     _callingStackFrameGetter = callingStackFrameGetter;
     _messageTextFormatter = messageTextFormatter;
     _filePath = string.Format("{0}{1}{2}.{3}.log",
         Path.GetTempPath(),
         Environment.NewLine,
         AppDomain.CurrentDomain.FriendlyName,
         Process.GetCurrentProcess().Id);
 }
Пример #34
0
        public IMessageSender GetMessageSender(MessageType type, IMessageCreator messageCreator, IClientOptions options)
        {
            switch (type)
            {
            case MessageType.Single:
                return(new SingleMessageSender(messageCreator, options));

            case MessageType.Multiple:
                return(new MultipleMessageSender(messageCreator, options));

            default:
                return(new SingleMessageSender(messageCreator, options));
            }
        }
Пример #35
0
        public EditTestController(Test test, ITestService service, ITestStateManager stateManager, ITestPresenter presenter, IMessageCreator messageBox)
        {
            _test         = test;
            _service      = service;
            _stateManager = stateManager;
            _presenter    = presenter;
            _messageBox   = messageBox;

            _runCommand = new ActionCommand(() =>
            {
                if (SaveChanges())
                {
                    _service.QueueTest(_test);
                }
            });

            _saveCommand   = new ActionCommand(() => SaveChanges());
            _cancelCommand = new ActionCommand(Cancel);
        }
Пример #36
0
 public SendDestinationCallback(EmsTemplate jmsTemplate, Destination destination, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreator = messageCreator;
 }
Пример #37
0
 public EmailService(ITemplateExecutor templateExecutor, IMessageCreator messageCreator, ISender sender)
 {
     this.templateExecutor = templateExecutor;
     this.messageCreator = messageCreator;
     this.sender = sender;
 }
Пример #38
0
 /// <summary>
 /// Send the given message.
 /// </summary>
 /// <param name="session">The session to operate on.</param>
 /// <param name="destination">The destination to send to.</param>
 /// <param name="messageCreator">The message creator callback to create a Message.</param>
 protected internal virtual void DoSend(ISession session, Destination destination, IMessageCreator messageCreator)
 {
     AssertUtils.ArgumentNotNull(messageCreator, "IMessageCreator must not be null");
     DoSend(session, destination, messageCreator, null);
 }
 public WeeeEmailServiceBuilder()
 {
     TemplateExecutor = A.Fake<ITemplateExecutor>();
     MessageCreator = A.Fake<IMessageCreator>();
     Sender = A.Fake<IWeeeSender>();
     Configuration = A.Fake<IWeeeEmailConfiguration>();
 }
Пример #40
0
        /// <summary> Send the given EMS message.</summary>
        /// <param name="session">the EMS Session to operate on
        /// </param>
        /// <param name="destination">the EMS Destination to send to
        /// </param>
        /// <param name="messageCreator">callback to create a EMS Message
        /// </param>
        /// <param name="messageCreatorDelegate">delegate callback to create a EMS Message
        /// </param>
        /// <exception cref="EMSException">If there is any problem accessing the EMS API</exception>
        protected internal virtual void DoSend(ISession session, Destination destination, IMessageCreator messageCreator,
                                               MessageCreatorDelegate messageCreatorDelegate)
        {


            IMessageProducer producer = CreateProducer(session, destination);            
            try
            {
                
                Message message;
                if (messageCreator != null)
                {
                    message = messageCreator.CreateMessage(session) ;
                }
                else {
                    message = messageCreatorDelegate(session);
                }
                if (logger.IsDebugEnabled)
                {
                    logger.Debug("Sending created message [" + message + "]");
                }
                DoSend(producer, message);

                // Check commit, avoid commit call is Session transaction is externally coordinated.
                if (session.Transacted && IsSessionLocallyTransacted(session))
                {
                    // Transacted session created by this template -> commit.
                    EmsUtils.CommitIfNecessary(session);
                }
            }
            finally
            {
                EmsUtils.CloseMessageProducer(producer);
            }
        }
Пример #41
0
 /// <summary> Send a message to the default destination.
 /// <p>This will only work with a default destination specified!</p>
 /// </summary>
 /// <param name="messageCreator">callback to create a message
 /// </param>
 /// <exception cref="EMSException">If there is any problem accessing the EMS API</exception>
 public void Send(IMessageCreator messageCreator)
 {
     CheckDefaultDestination();
     if (DefaultDestination != null)
     {
         Send(DefaultDestination, messageCreator);
     }
     else
     {
         Send(DefaultDestinationName, messageCreator);
     }
 }
 /// <summary>
 /// Creates a new instance of <see cref="TestableIncomingLogicalMessageContext" />.
 /// </summary>
 public TestableIncomingLogicalMessageContext(IMessageCreator messageCreator = null) : base(messageCreator)
 {
 }
 /// <summary>
 /// Creates a new instance of <see cref="TestableIncomingContext" />.
 /// </summary>
 protected TestableIncomingContext(IMessageCreator messageCreator = null) : base(messageCreator)
 {
 }
 /// <summary>
 /// Creates a new instance of <see cref="TestableInvokeHandlerContext" />.
 /// </summary>
 public TestableInvokeHandlerContext(IMessageCreator messageCreator = null) : base(messageCreator)
 {
 }
Пример #45
0
 /// <summary> Send a message to the specified destination.
 /// The MessageCreator callback creates the message given a Session.
 /// </summary>
 /// <param name="destination">the destination to send this message to
 /// </param>
 /// <param name="messageCreator">callback to create a message
 /// </param>
 /// <exception cref="EMSException">If there is any problem accessing the EMS API</exception>
 public void Send(Destination destination, IMessageCreator messageCreator)
 {
     
     Execute(new SendDestinationCallback(this, destination, messageCreator), false);
 }
Пример #46
0
 /// <summary> Send a message to the specified destination.
 /// The MessageCreator callback creates the message given a Session.
 /// </summary>
 /// <param name="destinationName">the destination to send this message to
 /// </param>
 /// <param name="messageCreator">callback to create a message
 /// </param>
 /// <exception cref="EMSException">If there is any problem accessing the EMS API</exception>
 public void Send(string destinationName, IMessageCreator messageCreator)
 {
     Execute(new SendDestinationCallback(this, destinationName, messageCreator), false);
 }
Пример #47
0
 public SendDestinationCallback(EmsTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreator = messageCreator;
 }
Пример #48
0
        /// <summary>
        /// Removes the message creator.
        /// </summary>
        /// <param name="creator">Creator.</param>
        public void RemoveMessageCreator(IMessageCreator creator)
        {
            Logger.Log.AddLogEntry(LogLevel.Fine, ClassName, "Removing message creator '{0}'",
                creator.GetType().ToString());

            creator.MessageCreated -= HandleMessageCreated;
        }