Ejemplo n.º 1
0
        /// <summary>
        /// Internal use only
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="arguments"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static void OnEventRaised(List <object?> arguments, object instance, string name)
        {
            var type    = instance.GetType();
            var factory = type.GetPrivateFieldInfo(ProxyFactoryFieldName).GetValue(instance) as EmptyProxyFactory
                          ?? throw new InvalidOperationException($"{ProxyFactoryFieldName} is null");

            var eventInfo      = type.GetEventInfo(name);
            var eventEventArgs = new EventEventArgs(arguments, eventInfo, factory);

            factory.EventRaised?.Invoke(instance, eventEventArgs);

            if (eventEventArgs.IsCanceled)
            {
                return;
            }

            var field = type
                        .GetPrivateFieldInfo(name)
                        .GetValue(instance);

            if (field != null)
            {
                // ReSharper disable once ConstantNullCoalescingCondition
                var handlerType = eventInfo.EventHandlerType ?? throw new InvalidOperationException("HandlerType is null");
                handlerType.GetMethodInfo(nameof(EventHandler.Invoke))
                .Invoke(field, arguments.ToArray());
            }

            factory.EventCompleted?.Invoke(instance, eventEventArgs);
        }
Ejemplo n.º 2
0
        public void ControllerDoesntRaisesDetectEvent()
        {
            List <string> tags = new List <string>();

            tags.Add("T1");
            Event        e      = new Event(DateTime.Now, "entered area", "Notification", tags);
            List <Event> events = new List <Event>();
            //events.Add(e);


            EventEventArgs _eResults = new EventEventArgs()
            {
                Events = events
            };

            //Fake listener
            _uut.DetectEvent += (sender, output2) => _eResults = output2;


            _eventdetector.DetectEvents(t).Returns(events);

            // Raise Event
            _relay.RelayEvent += Raise.EventWith(this, args);

            // Assertions
            Assert.That(_eResults.Events.Count.Equals(0));
        }
 private void _onEngineEventLocated(object o, EventEventArgs e) // when new event was created
 {
     Debug.WriteLine(e.Event?.EventName, "EventLocated notified");
     if (e.Event == null)
     {
         return;
     }
     OnUiThread(() =>
     {
         var evm = Find(e.Event, true);
         if (evm != null)
         {
             evm.UpdateLocation();
         }
         else
         {
             EventPanelViewmodelBase vm = PlaceEventInRundown(e.Event, false);
             if (vm != null &&
                 e.Event.EventType != TEventType.StillImage &&
                 e.Event == EngineViewmodel.LastAddedEvent)
             {
                 vm.IsSelected = true;
                 EngineViewmodel.ClearSelection();
                 if (e.Event.EventType == TEventType.Rundown)
                 {
                     vm.IsExpanded = true;
                 }
             }
             (vm as EventPanelRundownElementViewmodelBase)?.VerifyIsInvalidInSchedule();
         }
     });
 }
Ejemplo n.º 4
0
        private bool OnEventExecuting(Event evt)
        {
            var args = new EventEventArgs(evt);

            EventExecuting?.Invoke(null, args);
            return(!args.Cancel);
        }
Ejemplo n.º 5
0
 public void Setup()
 {
     _controller    = Substitute.For <IController>();
     _uut           = new Renderer(_controller);
     _resultsTracks = new TrackEventArgs(); // "Fake" listener
     _resultEvents  = new EventEventArgs();
 }
 private void _engine_EventDeleted(object sender, EventEventArgs e)
 {
     OnUiThread(() =>
     {
         var evm = Find(e.Event, true);
         evm?.Dispose();
     });
 }
 private void _engine_EventDeleted(object sender, EventEventArgs e)
 {
     Application.Current.Dispatcher.BeginInvoke((Action) delegate
     {
         var evm = Find(e.Event);
         evm?.Dispose();
     });
 }
Ejemplo n.º 8
0
 private void DetectEventHandler(object sender, EventEventArgs e)
 {
     events = e.Events;
     RenderEvent(this, new EventEventArgs()
     {
         Events = events
     });
 }
Ejemplo n.º 9
0
        protected void OnNewEvent(EventEventArgs e)
        {
            var handler = Interlocked.CompareExchange(ref NewEvent, null, null);

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 10
0
        internal void OnEvent(EventEventArgs e)
        {
            var handler = Interlocked.CompareExchange(ref Event, null, null);

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 11
0
        protected void OnFeedback(EventEventArgs e)
        {
            var handler = Interlocked.CompareExchange(ref Feedback, null, null);

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 12
0
        private void RaiseEventCreatedEvent(EventCreateModel eventCreateModel)
        {
            var handler = EventCreated;

            if (handler != null)
            {
                EventEventArgs e = new EventEventArgs(eventCreateModel);
                handler(this, e);
            }
        }
Ejemplo n.º 13
0
        protected void OnTradeFailed(EventEventArgs e)
        {
            OnNewEvent(e);
            var handler = Interlocked.CompareExchange(ref TradeFailed, null, null);

            if (handler != null)
            {
                handler(this, e);
            }
        }
Ejemplo n.º 14
0
        public void Setup()
        {
            _controller   = Substitute.For <IController>();
            _uut          = new Renderer(_controller);
            _resultTracks = new TrackEventArgs(); // "Fake" listener
            _resultEvents = new EventEventArgs();

            // Make "fake" listener on Renderer class, that has the TrackEventArgs, that can be Asserted on
            _uut.RenderTracks += (sender, output) => _resultTracks = output;
            _uut.RenderEvent  += (sender, outputEvent) => _resultEvents = outputEvent;
        }
Ejemplo n.º 15
0
        void OnSubscriptionManagerEventAdded(object _, EventEventArgs @event)
        {
            if (!_connection.IsConnected)
            {
                _connection.TryConnect(ResiliencePolicies.ConnectionPolicyFactory);
            }

            if (_consumerChannel == null)
            {
                _consumerChannel = CreateConsumerChannel(@event.EventName);
            }
        }
Ejemplo n.º 16
0
 private void OnEventRemoved(object _, EventEventArgs e)
 {
     lock (locker)
     {
         CancellationTokenSource tokenSource;
         if (cancellationTokenPerSubscriptionDictionary.TryGetValue(e.EventName, out tokenSource))
         {
             tokenSource.Cancel();
             cancellationTokenPerSubscriptionDictionary.Remove(e.EventName);
         }
     }
 }
Ejemplo n.º 17
0
        private void editEvent_Click(object sender, RoutedEventArgs e)
        {
            var evt = ((FrameworkElement)sender).DataContext as OlympiadPanelVm.EventVm;

            if (EventSelected != null)
            {
                var args = new EventEventArgs()
                {
                    EventCode = evt.Code, OlympiadId = ViewModel.OlympiadId
                };
                EventSelected(this, args);
            }
        }
Ejemplo n.º 18
0
        public void UutRenderEventsFromController()
        {
            List <Event> e = new List <Event>();

            e.Add(new Event(DateTime.Now, "Entered Area", "Notification", new List <string>()));
            var args = new EventEventArgs()
            {
                Events = e
            };

            _controller.DetectEvent += Raise.EventWith(this, args);

            Assert.That(_resultEvents.Events.Count == 1);
        }
Ejemplo n.º 19
0
        void OnSubscriptionManagerEventAdded(object _, EventEventArgs @event)
        {
            if (!_connection.IsConnected)
            {
                _connection.TryConnect();
            }

            using (var channel = _connection.CreateModel())
            {
                channel.QueueBind(
                    queue: _queueName,
                    exchange: ExchangeName,
                    routingKey: @event.EventName
                    );
            }
        }
Ejemplo n.º 20
0
        void OnSubscriptionManagerEventRemoved(object _, EventEventArgs @event)
        {
            if (!_connection.IsConnected)
            {
                _connection.TryConnect(ResiliencePolicies.ConnectionPolicyFactory);
            }

            using (var channel = _connection.CreateModel())
            {
                if (!_subscriptionManager.IsEmpty)
                {
                    return;
                }

                _consumerChannel.Close();
            }
        }
Ejemplo n.º 21
0
        private void RenderEventHandler(object sender, EventEventArgs e)
        {
            warningEvents = new List<Event>();
            foreach (var item in e.Events)
            {
                if (item.Category == "Notification")
                {
                    notificationEvents.Add(item);
                    }
                else if (item.Category == "Warning")
                {
                    warningEvents.Add(item);
                }
            }
            UpdateWarnings();

            
        }
Ejemplo n.º 22
0
 private void OnEventAdded(object sender, EventEventArgs e)
 {
     lock (locker)
     {
         if (!cancellationTokenPerSubscriptionDictionary.ContainsKey(e.EventName))
         {
             cancellationTokenPerSubscriptionDictionary.Add(e.EventName, new CancellationTokenSource());
         }
         else
         {
             CancellationTokenSource cancellationTokenSource;
             if (cancellationTokenPerSubscriptionDictionary.TryGetValue(e.EventName, out cancellationTokenSource))
             {
                 cancellationTokenSource.Dispose();
                 cancellationTokenPerSubscriptionDictionary[e.EventName] = new CancellationTokenSource();
             }
         }
     }
 }
Ejemplo n.º 23
0
        public override bool Event_Received(object sender, EventEventArgs args)
        {
            var  rootId  = new CoolQIdentity(2241521134, MessageType.Private);
            bool handled = false;
            var  obj     = args.ParsedObject;

            switch (obj)
            {
            case string str:
                SendMessageAsync(new CoolQRouteMessage(str, rootId));
                break;

            case FriendRequest friendRequest:
            {
                var msg = string.Format("{0} ({1})邀请加我为好友",
                                        CoolQHttpApiClient.GetStrangerInfo(friendRequest.UserId.ToString()).Data?.Nickname,
                                        friendRequest.UserId);
                SendMessageAsync(new CoolQRouteMessage(msg, rootId));
                break;
            }

            case GroupInvite groupInvite:
                if (groupInvite.SubType == "invite")
                {
                    var msg = string.Format("{0} ({1})邀请我加入群{2}",
                                            CoolQHttpApiClient.GetStrangerInfo(groupInvite.UserId.ToString()).Data?.Nickname,
                                            groupInvite.UserId,
                                            groupInvite.GroupId);
                    SendMessageAsync(new CoolQRouteMessage(msg, rootId));
                }
                break;

            case GroupAdminChange groupAdminChange:
                break;
            }

            return(handled);
        }
Ejemplo n.º 24
0
        void OnSubscriptionManagerEventRemoved(object _, EventEventArgs @event)
        {
            if (!_connection.IsConnected)
            {
                _connection.TryConnect();
            }

            using (var channel = _connection.CreateModel())
            {
                channel.QueueUnbind(
                    queue: _queueName,
                    exchange: ExchangeName,
                    routingKey: @event.EventName
                    );

                if (!_subscriptionManager.IsEmpty)
                {
                    return;
                }

                _queueName = string.Empty;
                _consumerChannel.Close();
            }
        }
Ejemplo n.º 25
0
 // Handler
 protected virtual void OnEventChanged(EventEventArgs e)
 {
     EventChanged?.Invoke(this, e);
 }
Ejemplo n.º 26
0
 private void MSpeechRecognizer_Event(object sender, EventEventArgs e)
 {
 }
 public void OnEvent(object sender, EventEventArgs e)
 {
     Debug.WriteLine("OnEvent: " + e?.EventType);
 }
Ejemplo n.º 28
0
 private void Receptor_OnEvent(object Sender, EventEventArgs e)
 {
     this.Dispatcher.Invoke(new Action(() => this.EventListView.Items.Add(new EventItem(e.Event))));
 }