public static bool Perform() { try { if (!GameUtils.IsInstalled(ProductVersion.EP2)) { return(true); } if (EventTracker.Instance == null) { return(false); } if (EventTracker.Instance.mListeners == null) { return(false); } // Required to stop a hang when an inactive firefighter reaches level 10 Dictionary <ulong, List <EventListener> > dictionary; if (!EventTracker.Instance.mListeners.TryGetValue((ulong)EventTypeId.kActiveCareerAdvanceLevel, out dictionary)) { return(false); } foreach (List <EventListener> list in dictionary.Values) { if (list == null) { continue; } foreach (EventListener listener in list) { if (listener == null) { continue; } DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if ((target != null) && (delListener.mProcessEvent != null)) { delListener.mProcessEvent = new Middleman(delListener.mProcessEvent).OnEvent; } } } } } catch (Exception e) { Common.Exception("DisableRewardCeremonies", e); } return(true); }
public void TestClientContinuousQueryReceivesEventsFromServerCache() { const int count = 10000; var cache = Client.GetOrCreateCache <int, int>(TestUtils.TestName); var receiveCount = 0; var listener = new DelegateListener <int, int>(e => { Interlocked.Increment(ref receiveCount); }); using (cache.QueryContinuous(new ContinuousQueryClient <int, int>(listener))) { var serverCache = Ignition.GetIgnite("1").GetCache <int, int>(cache.Name); for (var i = 0; i < count; i++) { serverCache.Put(i, i); } TestUtils.WaitForTrueCondition(() => receiveCount == count); } }
public void TestContinuousQueryWithFilterReceivesOnlyMatchingEvents() { var cache = Client.GetOrCreateCache <int, int>(TestUtils.TestName); ICacheEntryEvent <int, int> lastEvt = null; var listener = new DelegateListener <int, int>(e => lastEvt = e); var qry = new ContinuousQueryClient <int, int>(listener) { Filter = new OddKeyFilter() }; using (cache.QueryContinuous(qry)) { cache.Put(0, 0); TestUtils.WaitForTrueCondition(() => OddKeyFilter.LastKey == 0); Assert.IsNull(lastEvt); cache.Put(5, 5); TestUtils.WaitForTrueCondition(() => OddKeyFilter.LastKey == 5); TestUtils.WaitForTrueCondition(() => lastEvt != null); Assert.IsNotNull(lastEvt); Assert.AreEqual(5, lastEvt.Key); cache.Put(8, 8); TestUtils.WaitForTrueCondition(() => OddKeyFilter.LastKey == 8); Assert.AreEqual(5, lastEvt.Key); } }
public DocumentationTagger(ITextView textView, ITextBuffer buffer, IEventAggregator eventAggregator) { _textView = textView; _buffer = buffer; _eventAggregator = eventAggregator; _filename = buffer.GetFileName(); _codyDocsFilename = textView.TextBuffer.GetCodyDocsFileName(); snapshot = textView.TextBuffer.CurrentSnapshot; _documentationAddedListener = new DelegateListener <DocumentationAddedEvent>(OnDocumentationAdded); _eventAggregator.AddListener <DocumentationAddedEvent>(_documentationAddedListener); _documentSavedListener = new DelegateListener <DocumentSavedEvent>(OnDocumentSaved); _eventAggregator.AddListener <DocumentSavedEvent>(_documentSavedListener); _documentatiClosedListener = new DelegateListener <DocumentClosedEvent>(OnDocumentatClosed); _eventAggregator.AddListener <DocumentClosedEvent>(_documentatiClosedListener); _documentationUpdatedListener = new DelegateListener <DocumentationUpdatedEvent>(OnDocumentationUpdated); _eventAggregator.AddListener <DocumentationUpdatedEvent>(_documentationUpdatedListener); _documentationDeletedListener = new DelegateListener <DocumentationDeletedEvent>(OnDocumentationDeleted); _eventAggregator.AddListener <DocumentationDeletedEvent>(_documentationDeletedListener); //TODO: Add event aggregator listener to documentation changed on tracking Span X //TODO: Add event aggregator listener to documentation deleted on tracking Span X CreateTrackingSpans(); }
public static IEventSubscriptionManager AddListener <T>(this IEventSubscriptionManager eventAggregator, Action <T> listener) { var delegateListener = new DelegateListener <T>(listener); eventAggregator.AddListener(delegateListener); return(eventAggregator); }
public IEventAggregator AddListener <T>(Action handler) { var delegateListener = new DelegateListener <T>(msg => handler()); AddListener(delegateListener); return(this); }
public HighlightTagger(IWpfTextView view, ITagAggregator <DocumentationTag> tagAggregator, IEventAggregator eventAggregator) { _tagAggregator = tagAggregator; _eventAggregator = eventAggregator; _tagAggregator.TagsChanged += OnTagsChanged; _buffer = view.TextBuffer; _documentatiClosedListener = new DelegateListener <DocumentClosedEvent>(OnDocumentatClosed); eventAggregator.AddListener <DocumentClosedEvent>(_documentatiClosedListener); _documentationMouseHoverListener = new DelegateListener <MouseHoverOnDocumentationEvent>(OnMouseHover); eventAggregator.AddListener <MouseHoverOnDocumentationEvent>(_documentationMouseHoverListener); _filename = _buffer.GetFileName(); }
public virtual void execute(T execution) { CoreModelElement scope = getScope(execution); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.List<org.camunda.bpm.engine.delegate.DelegateListener<? extends org.camunda.bpm.engine.delegate.BaseDelegateExecution>> listeners = getListeners(scope, execution); IList <DelegateListener <BaseDelegateExecution> > listeners = getListeners(scope, execution); int listenerIndex = execution.ListenerIndex; if (listenerIndex == 0) { execution = eventNotificationsStarted(execution); } if (!isSkipNotifyListeners(execution)) { if (listeners.Count > listenerIndex) { execution.EventName = EventName; execution.EventSource = scope; //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.camunda.bpm.engine.delegate.DelegateListener<? extends org.camunda.bpm.engine.delegate.BaseDelegateExecution> listener = listeners.get(listenerIndex); DelegateListener <BaseDelegateExecution> listener = listeners[listenerIndex]; execution.ListenerIndex = listenerIndex + 1; try { execution.invokeListener(listener); } catch (Exception ex) { eventNotificationsFailed(execution, ex); // do not continue listener invocation once a listener has failed return; } execution.performOperationSync(this); } else { resetListeners(execution); eventNotificationsCompleted(execution); } } else { eventNotificationsCompleted(execution); } }
public override void verifyListener <T1>(DelegateListener <T1> listener) where T1 : [email protected] { assertTrue(listener is ClassDelegateCaseExecutionListener); ClassDelegateCaseExecutionListener classDelegateListener = (ClassDelegateCaseExecutionListener)listener; assertEquals(CLASS_NAME, classDelegateListener.ClassName); IList <FieldDeclaration> fieldDeclarations = classDelegateListener.FieldDeclarations; assertEquals(fieldSpecs.Count, fieldDeclarations.Count); for (int i = 0; i < fieldDeclarations.Count; i++) { FieldDeclaration declaration = fieldDeclarations[i]; FieldSpec matchingFieldSpec = fieldSpecs[i]; matchingFieldSpec.verify(declaration); } }
public override void verifyListener <T1>(DelegateListener <T1> listener) where T1 : [email protected] { assertTrue(listener is DelegateExpressionCaseExecutionListener); DelegateExpressionCaseExecutionListener delegateExpressionListener = (DelegateExpressionCaseExecutionListener)listener; assertEquals(DELEGATE_EXPRESSION, delegateExpressionListener.ExpressionText); IList <FieldDeclaration> fieldDeclarations = delegateExpressionListener.FieldDeclarations; assertEquals(fieldSpecs.Count, fieldDeclarations.Count); for (int i = 0; i < fieldDeclarations.Count; i++) { FieldDeclaration declaration = fieldDeclarations[i]; FieldSpec matchingFieldSpec = fieldSpecs[i]; matchingFieldSpec.verify(declaration); } }
public void TestContinuousQueryWithJavaFilterReceivesOnlyMatchingEvents() { var cache = Client.GetOrCreateCache <int, int>(TestUtils.TestName); var evts = new ConcurrentBag <int>(); var listener = new DelegateListener <int, int>(e => evts.Add(e.Key)); var qry = new ContinuousQueryClient <int, int>(listener) { Filter = new JavaObject("org.apache.ignite.platform.PlatformCacheEntryEvenKeyEventFilter", null) .ToCacheEntryEventFilter <int, int>() }; using (cache.QueryContinuous(qry)) { cache.PutAll(Enumerable.Range(1, 5).ToDictionary(x => x, x => x)); } TestUtils.WaitForTrueCondition(() => evts.Count == 2); CollectionAssert.AreEquivalent(new[] { 2, 4 }, evts); }
public DocumentedCodeHighlighterTagger(ITextView textView, ITextBuffer buffer, IEventAggregator eventAggregator) { _textView = textView; _buffer = buffer; _eventAggregator = eventAggregator; _filename = GetFileName(buffer); _documentationAddedListener = new DelegateListener <DocumentationAddedEvent>(OnDocumentationAdded); _eventAggregator.AddListener <DocumentationAddedEvent>(_documentationAddedListener); _documentSavedListener = new DelegateListener <DocumentSavedEvent>(OnDocumentSaved); _eventAggregator.AddListener <DocumentSavedEvent>(_documentSavedListener); _documentatiClosedListener = new DelegateListener <DocumentClosedEvent>(OnDocumentatClosed); _eventAggregator.AddListener <DocumentClosedEvent>(_documentatiClosedListener); _documentationUpdatedListener = new DelegateListener <DocumentationUpdatedEvent>(OnDocumentationUpdated); _eventAggregator.AddListener <DocumentationUpdatedEvent>(_documentationUpdatedListener); _documentationDeletedListener = new DelegateListener <DocumentationDeletedEvent>(OnDocumentationDeleted); _eventAggregator.AddListener <DocumentationDeletedEvent>(_documentationDeletedListener); //TODO: Add event aggregator listener to documentation changed on tracking Span X //TODO: Add event aggregator listener to documentation deleted on tracking Span X CreateTrackingSpans(); }
protected override void Perform(EventListener obj, object parent, FieldInfo field) { if (!DereferenceManager.HasBeenDestroyed(obj.TargetObject)) { return; } if (DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), false, false)) { EventTracker.RemoveListener(obj); obj.CompletionDelegate = null; obj.mScriptObject = null; obj.mTargetObject = null; DelegateListener delListener = obj as DelegateListener; if (delListener != null) { delListener.mProcessEvent = null; } DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), true, false); } }
protected override bool Run(SimDescription me, bool singleSelection) { Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { List <CareerLevel> levels = AllLevels(career); if ((levels == null) || (levels.Count == 0)) { return(false); } List <Item> allOptions = new List <Item>(); foreach (CareerLevel level in levels) { allOptions.Add(new Item(me, level)); } Item choice = new CommonSelection <Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } List <CareerLevel> order = null; if (choice.mLevel.Level < me.Occupation.CareerLevel) { order = LevelsBetween(choice.mLevel, career.CurLevel, true); } else { order = LevelsBetween(career.CurLevel, choice.mLevel, false); } if (order.Count == 0) { List <CareerLevel> oldBranches = AllBranches(career.CurLevel); List <CareerLevel> newBranches = AllBranches(choice.mLevel); CareerLevel common = null; foreach (CareerLevel branch in newBranches) { if (oldBranches.Contains(branch)) { common = branch; break; } } if (common != null) { order.AddRange(LevelsBetween(common, career.CurLevel, true)); order.AddRange(LevelsBetween(common, choice.mLevel, false)); } } foreach (CareerLevel level in order) { if (career.CurLevel == level) { continue; } if (career.CurLevel.LastLevel == level) { career.DemoteSim(); } else { Promote(career, level); } } return(true); } else { XpBasedCareer xpCareer = me.Occupation as XpBasedCareer; if (xpCareer != null) { List <Item> allOptions = new List <Item>(); for (int level = 1; level <= xpCareer.HighestLevel; level++) { allOptions.Add(new Item(xpCareer.LevelJobTitle(level), level)); } Item choice = new CommonSelection <Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } if (choice.mXPLevel < me.Occupation.CareerLevel) { xpCareer.mLevel = choice.mXPLevel; xpCareer.mXp = 0; } else { Dictionary <DelegateListener, ProcessEventDelegate> retain = new Dictionary <DelegateListener, ProcessEventDelegate>(); Dictionary <ulong, List <EventListener> > dictionary; EventTracker.Instance.mListeners.TryGetValue((ulong)EventTypeId.kActiveCareerAdvanceLevel, out dictionary); // Required to stop a hang when an inactive firefighter is promoted to level 10 if (me.Household != Household.ActiveHousehold) { foreach (List <EventListener> list in dictionary.Values) { foreach (EventListener listener in list) { DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if (target != null) { retain.Add(delListener, delListener.mProcessEvent); delListener.mProcessEvent = OnStub; } } } } } xpCareer.ForcePromoteToLevel(choice.mXPLevel); if (me.Household != Household.ActiveHousehold) { foreach (List <EventListener> list in dictionary.Values) { foreach (EventListener listener in list) { DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if (target != null) { delListener.mProcessEvent = retain[delListener]; } } } } } } return(true); } } return(false); }
protected internal abstract void verifyListener <T1>(DelegateListener <T1> listener) where T1 : [email protected];
public virtual void addListener <T1>(string eventName, DelegateListener <T1> listener, int index) where T1 : [email protected] { addListenerToMap(listeners, eventName, listener, index); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings({ "rawtypes", "unchecked" }) public void invokeListener(org.camunda.bpm.engine.delegate.DelegateListener listener) throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void invokeListener(DelegateListener listener) { listener.notify(this); }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("CleanupSituationEvents"); EventTracker instance = EventTracker.Instance; List <ulong> removes2 = new List <ulong>(); foreach (KeyValuePair <ulong, Dictionary <ulong, List <EventListener> > > lookup in instance.mListeners) { List <ulong> removes = new List <ulong>(); foreach (KeyValuePair <ulong, List <EventListener> > lookup2 in lookup.Value) { int index = 0; while (index < lookup2.Value.Count) { DelegateListener dListener = lookup2.Value[index] as DelegateListener; index++; if (dListener == null) { continue; } if (dListener.mProcessEvent == null) { continue; } if (CleanupSituationInteractions.TestCallback(dListener.mProcessEvent, "ProcessEvent")) { string name = dListener.mProcessEvent.Method.ToString(); if (dListener.mProcessEvent.Target != null) { name = dListener.mProcessEvent.Target.GetType().ToString() + " " + name; } Overwatch.Log(name + ": Bogus Situation Event Dropped"); index--; lookup2.Value.RemoveAt(index); } } if (lookup2.Value.Count == 0) { removes.Add(lookup2.Key); } } foreach (ulong remove in removes) { lookup.Value.Remove(remove); } if (lookup.Value.Count == 0) { removes2.Add(lookup.Key); } } foreach (ulong remove in removes2) { instance.mListeners.Remove(remove); } }
public virtual void addBuiltInListener <T1>(string eventName, DelegateListener <T1> listener) where T1 : [email protected] { addBuiltInListener(eventName, listener, -1); }