protected internal void RaiseZebraIpChangedEvent()
 {
     if (EventRaiser != null)
     {
         EventRaiser.Raise(ref ZebraIpChanged, ZebraPrinterIP);
     }
 }
 protected internal void RaiseZplTemplateChanged()
 {
     if (EventRaiser != null)
     {
         EventRaiser.Raise(ref ZplTemplateChanged, ZplTemplateFile);
     }
 }
 /// <summary>A helper method used by derived types that asynchronously raises an event on the application's desired thread.</summary>
 /// <typeparam name="T">The <see cref="T:System.EventArgs"/> type identifying the type of object that gets raised with the event"/></typeparam>
 /// <param name="callback">The protected virtual method that will raise the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> object that should be passed to the protected virtual method raising the event.</param>
 private void PostEvent <T>(EventRaiser <T> callback, T e) where T : EventArgs
 {
     if (m_synchronizationContext != null)
     {
         m_synchronizationContext.Post(delegate(Object state) { callback((T)state); }, e);
     }
 }
Example #4
0
        private static void _RegisterTSLStorageExtension(IGenericCellOperations genericCellOps, IStorageSchema storageSchema)
        {
            if (genericCellOps == null)
            {
                throw new ArgumentNullException("genericCellOps");
            }
            if (storageSchema == null)
            {
                throw new ArgumentNullException("storageSchema");
            }
            if (genericCellOps.GetType().Assembly != storageSchema.GetType().Assembly)
            {
                throw new ArgumentException("Components being registered are from different storage extensions.");
            }


            if (storageSchema is IStorageSchemaUpdateNotifier notifier)
            {
                notifier.StorageSchemaUpdated += StorageSchemaUpdated;
            }

            EventRaiser.RaiseStorageEvent(StorageSchemaUpdated, nameof(StorageSchemaUpdated));

            if (storage_schema is IStorageSchemaUpdateNotifier old_notifier)
            {
                old_notifier.StorageSchemaUpdated -= StorageSchemaUpdated;
            }

            generic_cell_ops = genericCellOps;
            storage_schema   = storageSchema;
        }
Example #5
0
 protected override void PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken)
 {
     if (!ShouldStartIndexing(indexingOptions))
     {
         return;
     }
     if (SwitchOnRebuild)
     {
         DoRebuild(indexingOptions);
         ISearchService searchService = SearchService;
         EventRaiser.RaiseRebuildEndEvent(new SwitchOnRebuildEventRemote()
         {
             IndexName             = Name,
             SearchCloudIndexName  = SearchCloudIndexName,
             RebuildCloudIndexName = RebuildCloudIndexName
         });
         Thread.Sleep(OldIndexCleanUpDelay);
         searchService.Cleanup();
     }
     else
     {
         Reset();
         DoRebuild(indexingOptions);
     }
 }
Example #6
0
        /// <summary>
        /// Provides the ability to raise an event that has had an expectation created
        /// </summary>
        /// <typeparam name="T">the mocked type</typeparam>
        /// <param name="instance">the mocked instance</param>
        /// <param name="eventSubscription">the event that has had an expectation created</param>
        /// <param name="args">arguments used to the raise event</param>
        /// <returns>collection of the actual calls</returns>
        /// <exception cref="System.ArgumentNullException">thrown when the instance is null</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// thrown when the instance cannot be identified as a mocked object or the given method is not an event
        /// </exception>
        public static void Raise <T>(this T instance, Action <T> eventSubscription, object[] args)
            where T : class
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance", "Events cannot be raised from a null object or instance.");
            }

            var container = GetExpectationContainer(instance);

            if (container == null)
            {
                throw new ArgumentOutOfRangeException("instance", "Events can only be raised from a mocked object or instance.");
            }

            var expectation = new ExpectEvent();

            container.MarkForAssertion(expectation);

            try
            {
                eventSubscription(instance);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("Exception caught while identifying event", ex);
            }

            if (container.ExpectationMarked)
            {
                throw new InvalidOperationException();
            }

            var method = expectation.Method;

            if (!method.IsSpecialName)
            {
                throw new InvalidOperationException("Raise method can only be used against events.");
            }

            var methodName = method.Name;

            if (!methodName.StartsWith("add_"))
            {
                throw new InvalidOperationException("Raise method can only be used against events.");
            }

            var eventName    = methodName.Substring(4);
            var subscription = container.GetEventSubscribers(eventName);

            if (subscription == null)
            {
                return;
            }

            var raiser = new EventRaiser(instance);

            raiser.Raise(subscription, args);
        }
Example #7
0
        private void OnCloseConnection(object sender, ConnectionCloseEventArgs e)
        {
            var connection = (IConnection)sender;

            connection.Closed -= CloseConnection;
            EventRaiser.SoftRaiseEvent(CloseConnection, this, e);
            connectionListenerMap.Remove(connection.Id);
        }
Example #8
0
        public override void Execute(CommandContext context)
        {
            var start = DateTime.Today;
            var end   = DateTime.Today + TimeSpan.FromDays(1);

            PipelineHelper.RunPipeline(start, end); // run the pipeline
            EventRaiser.RaiseEvent(start, end);
        }
Example #9
0
 protected void RaiseReceived(byte[] buffer, int offset, int count)
 {
     EventRaiser.SoftRaiseEvent(
         Received,
         this,
         new ConnectionBufferEventArgs(this, buffer, offset, count)
         );
 }
 public ContentInstaller(EventRaiser eventRaiser, IGameLocker gameLocker,
     IINstallerSessionFactory sessionFactory, IW6Api api) {
     _eventRaiser = eventRaiser;
     _sessionFactory = sessionFactory;
     _api = api;
     _gameLocker = gameLocker;
     _cleaner = new ContentCleaner();
 }
Example #11
0
 public ContentInstaller(EventRaiser eventRaiser, IGameLocker gameLocker,
                         IINstallerSessionFactory sessionFactory, IW6Api api)
 {
     _eventRaiser    = eventRaiser;
     _sessionFactory = sessionFactory;
     _api            = api;
     _gameLocker     = gameLocker;
     _cleaner        = new ContentCleaner();
 }
    public void WriteAll()
    {
        int b;

        while ((b = _source.ReadByte()) != -1)
        {
            _destination.WriteByte((byte)b);
            EventRaiser.Raise(ProgressChanged, this);     // Just one call here! Can't be less
        }
    }
Example #13
0
 /// <summary>
 /// Initialize timer with default values.
 /// </summary>
 private void Initialize()
 {
     _mode             = TimerMode.Periodic;
     _period           = Capabilities.periodMin;
     _resolution       = 1;
     IsRunning         = false;
     _timeProcPeriodic = TimerPeriodicEventCallback;
     _timeProcOneShot  = TimerOneShotEventCallback;
     _tickRaiser       = OnTick;
 }
Example #14
0
            public Aggregate(UserState state)
            {
                State = state;

                if (State.HasNewIdentity)
                {
                    EventRaiser.RaiseEvent(this, new UserCreated {
                        Id = State.Id
                    });
                }
            }
Example #15
0
        protected void AddNewConnection(IConnection connection)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            connections.Add(connection.Id, connection);
            connection.Closed += ConnectionClosed;
            EventRaiser.SoftRaiseEvent(OpenConnection, this, new ConnectionOpenEventArgs(connection, (IFormatter)Activator.CreateInstance(formatterType)));
            connection.BeginReceive();
        }
        // Initialize timer with default values.
        private void Initialize()
        {
            this.mode       = TimerMode.Periodic;
            this.period     = Capabilities.periodMin;
            this.resolution = 1;

            running = false;

            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            timeProcOneShot  = new TimeProc(TimerOneShotEventCallback);
            tickRaiser       = new EventRaiser(OnTick);
        }
Example #17
0
    public static void attachEvent()
    {
        var    raiser    = new EventRaiser();
        var    handler   = new Handler();
        string eventName = "SomethingHappened";
        var    eventinfo = raiser.GetType().GetEvent(eventName);

        eventinfo.AddEventHandler(raiser, EventProxy.Create(eventinfo, handler.HandleEvent));

        //or even just:
        eventinfo.AddEventHandler(raiser, EventProxy.Create(eventinfo, () => Console.WriteLine("!")));
    }
Example #18
0
        static void Main(string[] args)
        {
            var er = new EventRaiser();

            // er.DelegateTypeSelected += new System.EventHandler<DelegateTypeEventArgs>(DelegateTypes);
            // er.ExecutionCompleted += new System.EventHandler(Completed);

            // Delegate Inference
            er.DelegateTypeSelected += DelegateTypes;
            er.ExecutionCompleted   += Completed;

            er.Start();
        }
Example #19
0
        /// <summary>
        /// Raises the metrics changed event.
        /// </summary>
        /// <param name="oee">A value between 0 and 1 indicating the speedometer (for whatever metric).</param>
        protected internal void RaiseMetricsChangedEvent()
        {
            // callbacks will be raised in any case even if the state hasn't changed. to update WCF clients.
            if (EventRaiser != null)
            {
                var metrics = new MetricsDTO(
                    OverallItemCount,
                    Metrics.UpTime,
                    Metrics.DownTime,
                    Metrics.OverallEquipmentEfficiency);

                EventRaiser.Raise(ref MetricsChangedCallback, metrics);
            }
        }
Example #20
0
        // Initialize timer with default values.
        void Initialize()
        {
            this.mode       = TimerMode.PERIODIC;
            this.interval   = Capabilities.intervalMin;
            this.resolution = 1;

            running             = false;
            disposed            = false;
            synchronizingObject = null;
            site = null;

            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            timeProcOneShot  = new TimeProc(TimerOneShotEventCallback);
            tickRaiser       = new EventRaiser(OnTick);
        }
Example #21
0
        public void Close(ConnectionCloseReason reason)
        {
            lock (this)
            {
                if (IsClosed)
                {
                    return;
                }
                IsClosed = true;

                EventRaiser.SoftRaiseEvent(Closed, this, new ConnectionCloseEventArgs(this, reason));

                OnClose(reason);
            }
        }
Example #22
0
        public ThreadTimer()
            : this(ThreadTimerQueue.Instance)
        {
            if (!Stopwatch.IsHighResolution)
            {
                throw new NotImplementedException("Stopwatch is not IsHighResolution");
            }

            isRunning = false;
            mode = TimerMode.Periodic;
            resolution = TimeSpan.FromMilliseconds(1);
            period = resolution;

            tickRaiser = new EventRaiser(OnTick);
        }
Example #23
0
        public ThreadTimer()
            : this(ThreadTimerQueue.Instance)
        {
            if (!Stopwatch.IsHighResolution)
            {
                throw new NotImplementedException("Stopwatch is not IsHighResolution");
            }

            isRunning  = false;
            mode       = TimerMode.Periodic;
            resolution = TimeSpan.FromMilliseconds(1);
            period     = resolution;

            tickRaiser = new EventRaiser(OnTick);
        }
        public void TriggerAndVerifyRespondingToEvents()
        {
            MockRepository mocks       = new MockRepository();
            IView          viewStub    = mocks.Stub <IView>();
            IWebService    serviceMock = mocks.CreateMock <IWebService>();

            using (mocks.Record())
            {
                serviceMock.LogInfo("view loaded");
            }
            new Presenter(viewStub, serviceMock);
            IEventRaiser eventer = new EventRaiser((IMockedObject)viewStub, "Load");

            eventer.Raise(null, EventArgs.Empty);

            mocks.VerifyAll();
        }
        public async Task <IActionResult> RaiseFunds(EventRaiser eventRaiser)
        {
            EventRaiserwithoutid ver = new EventRaiserwithoutid();

            using (var httpClient = new HttpClient())
            {
                StringContent content = new StringContent(JsonConvert.SerializeObject(eventRaiser), Encoding.UTF8, "application/json");

                using (var response = await httpClient.PostAsync("http://localhost:7877/api/EventFund", content))
                {
                    string apiResponse = await response.Content.ReadAsStringAsync();

                    //ViewBag.Result = "Success";
                    ver = JsonConvert.DeserializeObject <EventRaiserwithoutid>(apiResponse);
                }
                return(RedirectToAction("Index"));
            }
        }
Example #26
0
        internal protected void RaiseModuleStateChangedEvent()
        {
            // callbacks will be raised in any case even if the state hasn't changed. to update WCF clients.
            if (EventRaiser != null)
            {
                EventRaiser.Raise(ref ModuleStateChangedCallback, this.ToDTO());
            }

            if (State != _oldModuleState)
            {
                var handle = ModuleStateChangedEvent;
                if (handle != null)
                {
                    handle(this, State);
                }
                _oldModuleState = State;
            }
        }
Example #27
0
        public void UsingEventRaiserCreate()
        {
            IWithEvents  eventHolder = (IWithEvents)mocks.Stub(typeof(IWithEvents));
            IEventRaiser eventRaiser = EventRaiser.Create(eventHolder, "Blah");
            bool         called      = false;

            eventHolder.Blah += delegate
            {
                called = true;
            };

            mocks.ReplayAll();

            eventRaiser.Raise(this, EventArgs.Empty);

            mocks.VerifyAll();

            Assert.True(called);
        }
Example #28
0
        public static void EventRaiseTest()
        {
            MockRepository rhinoEngine = new MockRepository();

            var view  = rhinoEngine.Stub <IView>();
            var model = rhinoEngine.DynamicMock <IModel>();

            using (rhinoEngine.Record())
            {
                model.DoSomeWork();
            }

            Presenter presenter = new Presenter(view, model);

            IEventRaiser raiser = EventRaiser.Create(view, "Load");

            raiser.Raise(null, null);

            rhinoEngine.Verify(model);
        }
Example #29
0
    public static void Main()
    {
        var raiser  = new EventRaiser();
        var handler = new Handler();
        //void delegate with no parameters
        string eventName = "SomethingHappened";
        var    eventinfo = raiser.GetType().GetEvent(eventName);

        eventinfo.AddEventHandler(raiser, EventProxy.Create(eventinfo, handler.HandleEvent));
        //void delegate with one parameter
        string eventName2 = "SomethingHappenedWithArg";
        var    eventInfo2 = raiser.GetType().GetEvent(eventName2);

        eventInfo2.AddEventHandler(raiser, EventProxy.Create <int>(eventInfo2, handler.HandleEventWithArg));

        //or even just:
        eventinfo.AddEventHandler(raiser, EventProxy.Create(eventinfo, () => Console.WriteLine("!")));
        eventInfo2.AddEventHandler(raiser, EventProxy.Create <int>(eventInfo2, i => Console.WriteLine(i + "!")));
        raiser.RaiseEvents();
    }
 private void InitializeDelegates()
 {
     this.onDataReceivedDelegate = new ConnectionDataEventRaiser( this.OnDataReceived );
     this.onDisconnectedDelegate = new ConnectionDataEventRaiser( this.OnDisconnected );
     this.onConnectedDelegate = new EventRaiser( this.OnConnected );
 }
Example #31
0
 public void TriggerCallbackEvent()
 {
     EventRaiser.Raise(ref AlarmsChanged, _moduleName);
 }
Example #32
0
        private void Initialize()
        {
            this.mode = Mode.Periodic;
            this.period = Capabilities.periodMin;
            this.resolution = 1;

            running = false;

            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            timeProcOneShot = new TimeProc(TimerOneShotEventCallback);
            tickRaiser = new EventRaiser(OnTick);
        }
        // Initialize timer with default values.
        private void Initialize()
        {
            this.mode = TimerMode.Periodic;
            this.period = Capabilities.periodMin;
            this.resolution = 1;

            this.running = false;

            this.timeProcPeriodic = this.TimerPeriodicEventCallback;
            this.timeProcOneShot = this.TimerOneShotEventCallback;
            this.tickRaiser = this.OnTick;
        }
Example #34
0
        // Initialize timer with default values.
        void Initialize()
        {
            this.mode = TimerMode.PERIODIC;
            this.interval = Capabilities.intervalMin;
            this.resolution = 1;

            running = false;
            disposed = false;
            synchronizingObject = null;
            site = null;

            timeProcPeriodic = new TimeProc(TimerPeriodicEventCallback);
            timeProcOneShot = new TimeProc(TimerOneShotEventCallback);
            tickRaiser = new EventRaiser(OnTick);
        }
    void RegisterEvents()
    {
        var r = new EventRaiser();

        r.ImportantThingHappened += GenericHandler.HandleAnyEvent;
    }
Example #36
0
 private void NotifyInterestedPartiesOfPropertyChange(string propertyName)
 {
     EventRaiser.RaisePropertyChangedEvent(this.PropertyChanged, this, propertyName);
 }