/// <inheritdoc />
 public async Task <IEventHook> CreateEventHookAsync(IEventHook eventHook, CancellationToken cancellationToken = default(CancellationToken))
 => await PostAsync <EventHook>(new HttpRequest
 {
     Uri     = "/api/v1/eventHooks",
     Verb    = HttpVerb.Post,
     Payload = eventHook,
 }, cancellationToken).ConfigureAwait(false);
		public void SetUp()
		{
			Helper.SetupTestMessaging();
			mock_event_hook = Substitute.For<IEventHook>();

			ObjectFactory.Configure(map=> map.For<IEventHook>().Use(mock_event_hook));

			node_factory = ObjectFactory.GetInstance<IReceiver>();
		}
 /// <inheritdoc />
 public async Task <IEventHook> UpdateEventHookAsync(IEventHook eventHook, string eventHookId, CancellationToken cancellationToken = default(CancellationToken))
 => await PutAsync <EventHook>(new HttpRequest
 {
     Uri            = "/api/v1/eventHooks/{eventHookId}",
     Verb           = HttpVerb.Put,
     Payload        = eventHook,
     PathParameters = new Dictionary <string, object>()
     {
         ["eventHookId"] = eventHookId,
     },
 }, cancellationToken).ConfigureAwait(false);
		public void setup()
		{
			_messagingBase = Substitute.For<IMessagingBase>();
			_sleeper = Substitute.For<ISleepWrapper>();
			_dispatcher = Substitute.For<IDispatch<byte[]>>();
			_dispatcherFactory = Substitute.For<IDispatcherFactory>();
			_dispatcherFactory.Create(Arg.Any<IWorkQueue<byte[]>>(), Arg.Any<IWorkerPool<byte[]>>()).Returns(_dispatcher);

			_queueFactory = Substitute.For<IOutgoingQueueFactory>();

			_eventHook1 = Substitute.For<IEventHook>();
			_eventHook2 = Substitute.For<IEventHook>();
			ObjectFactory.Configure(map => {
				map.For<IEventHook>().Use(_eventHook1);
				map.For<IEventHook>().Use(_eventHook2);
			});

			_subject = new SenderNode(_messagingBase, _dispatcherFactory, _sleeper,_queueFactory);
		}
 /// <summary>
 ///	Constructor to initialize the an event listener registration.
 /// </summary>
 /// <param name="instance">The instance of the <see cref="EventListener"/></param>
 /// <param name="eventHook">The hook to implement.</param>
 public EventListenerRegistration(EventListener instance, IEventHook eventHook)
 {
     Instance  = instance;
     EventHook = eventHook;
 }
        /// <summary>Initializes this instance.</summary>
        /// <param name="force">Force initialization, even if already initialized.</param>
        private void Initialize(bool force = false)
        {
            if ((this.initializeCalled && !force) || !Bootstrapper.GetInstance<IBrowserConfiguration>().Config.ScreenRefresher.Enabled)
            {
                return;
            }

            if (!this.initializeCalled)
            {
                this.timer.Elapsed += (sender, args) => this.ShowScreenRefresher();
                this.eventHook = Bootstrapper.GetInstance<IEventHook>();
                this.eventHook.Setup(WinEvents.EventSystemForeground);
                this.eventHook.EventFired +=
                    (hook, type, hwnd, idObject, child, thread, time) =>
                        this.Dispatcher.BeginInvoke(
                        new Action(() =>
                            NativeMethods.SetWindowPos(
                            new WindowInteropHelper(this).Handle,
                            NativeMethods.HwndTopmost,
                            0,
                            0,
                            0,
                            0,
                            NativeMethods.TopmostFlags)));
            }

            this.initializeCalled = true;
            this.config = Bootstrapper.GetInstance<IBrowserConfiguration>().Config.ScreenRefresher;
            Canvas.SetTop(this.RectangleAnimation, this.config.Height * -1);
            this.RectangleAnimation.Height = this.config.Height;

            if (this.config.RunAtStartup)
            {
                this.ShowScreenRefresher();
            }
            else
            {
                this.StartTimer();
            }
        }