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); } }
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; }
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); } }
/// <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); }
private void OnCloseConnection(object sender, ConnectionCloseEventArgs e) { var connection = (IConnection)sender; connection.Closed -= CloseConnection; EventRaiser.SoftRaiseEvent(CloseConnection, this, e); connectionListenerMap.Remove(connection.Id); }
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); }
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(); }
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 } }
/// <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; }
public Aggregate(UserState state) { State = state; if (State.HasNewIdentity) { EventRaiser.RaiseEvent(this, new UserCreated { Id = State.Id }); } }
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); }
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("!"))); }
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(); }
/// <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); } }
// 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); }
public void Close(ConnectionCloseReason reason) { lock (this) { if (IsClosed) { return; } IsClosed = true; EventRaiser.SoftRaiseEvent(Closed, this, new ConnectionCloseEventArgs(this, reason)); OnClose(reason); } }
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 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")); } }
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; } }
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); }
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); }
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 ); }
public void TriggerCallbackEvent() { EventRaiser.Raise(ref AlarmsChanged, _moduleName); }
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; }
// 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; }
private void NotifyInterestedPartiesOfPropertyChange(string propertyName) { EventRaiser.RaisePropertyChangedEvent(this.PropertyChanged, this, propertyName); }