public static void AddListener(int type, IEventListener listener, IEventDispatcher source = null) { if (!listeners.ContainsKey(type)) listeners.Add(type, new List<ListenerData>()); listeners[type].Add(new ListenerData(listener, source)); }
/////////////////////////////////////////////////////////// /** * Add a listener to the event manager that will receive any events of the * supplied event name. */ public static bool AddListener(IEventListener listener, string eventName) { if (!appQuitting) { if (listener == null || eventName == null) { Debug.Log("[EVENTMANAGER]: Failed to add listener: listener["+(listener == null ? "listener argument cannot be null" : listener.GetType().ToString())+"] eventName["+(eventName == null ? "eventName argument cannot be null" : eventName)+"]"); return false; } EventManager em = EventManager.getInstance(); if (!em.listenerTable.ContainsKey(eventName)) { //Debug.Log("adding listener for event ["+eventName+"]. listener ["+listener+"]"); em.listenerTable.Add(eventName, new ArrayList()); } ArrayList listenerList = em.listenerTable[eventName] as ArrayList; if (listenerList.Contains(listener)) { Debug.Log("[EVENTMANAGER]: listener["+(listener.GetType().ToString())+"] is already in list for eventName["+eventName+"]"); return false; } // Debug.Log("[EVENTMANAGER]: Added listener["+(listener.GetType().ToString())+"]"); listenerList.Add(listener); } /* else { Debug.Log("[EVENTMANAGER]: Addition of listener["+(listener.GetType().ToString())+"] skipped since app is quitting"); } */ return false; }
protected override ImporterConverterAbstract GetNext(IEventListener iel, CancellationToken iCancellationToken) { try { IMccDescompactor Sex = Context.RarManager.InstanciateExctractor(_FN, iel, Context); if (Sex == null) return null; bool exportsuccess = false; using (Sex) { exportsuccess = Sex.Extract(iel, iCancellationToken); } OutPutFiles = Sex.DescompactedFiles; if (iCancellationToken.IsCancellationRequested) { return null; } if (exportsuccess==false) return null; return new XMLImporter(Sex.RootXML, _ImportAllMetaData, Context.Folders.File) { Rerooter = Sex.Rerooter}; } catch (Exception e) { iel.Report(new UnknownRarError(_FN)); Trace.WriteLine("Decompressing problem " + e.ToString()); return null; } }
public void AddEventListener(IEventListener eventListener) { if (!(m_EventListeners.Contains(eventListener))) { m_EventListeners.Add(eventListener); } }
/** * Remove a listener from the specified event. */ public static bool DetachListener(IEventListener listener, string eventName) { if (!appQuitting) { EventManager em = EventManager.getInstance(); if (!em.listenerTable.ContainsKey(eventName)) { return false; } ArrayList listenerList = em.listenerTable[eventName] as ArrayList; if (!listenerList.Contains(listener)) { return false; } //Debug.Log("[EVENTMANAGER]: Removed listener["+(listener.GetType().ToString())+"]"); listenerList.Remove(listener); } /* else { Debug.Log("[EVENTMANAGER]: Removal of listener["+(listener.GetType().ToString())+"] skipped since app is quitting"); } */ return true; }
//searches ALL lists and removes listener from all of them. //pretty slow op; remove from individual lists if you can public static void RemoveListener(IEventListener listener) { foreach (EventType type in eventListenerMap.Keys) { eventListenerMap[type].Remove(listener); } }
/// <summary> /// 挂载一个消息监听器到当前的消息节点上 /// </summary> /// <param name="key">消息ID</param> /// <param name="listener">消息监听器</param> /// <returns>当前消息节点已经挂载了这个消息监听器那么返回false</returns> public bool AttachEventListener(int key, IEventListener listener) { if (listener == null) { return false; } if (!mListeners.ContainsKey(key)) { mListeners.Add(key, new List<IEventListener>() { listener }); return true; } if (mListeners[key].Contains(listener)) { return false; } int pos = 0; for (int i = 0; i < mListeners[key].Count; i++) { if (listener.EventPriority() > mListeners[key][i].EventPriority()) break; pos++; } mListeners[key].Insert(pos, listener); return true; }
public static void Initialize(IEventListener touchEventListener) { if (_initialized) return; /// Lack of constructors in native code, forces to /// initialize TouchPanel before we initialize event sink. /// We have only one touch panel right now. /// But this is to keep the options open for future. _activeTouchPanel = new TouchPanel(); _activeTouchPanel.Enabled = true; /// Add a touch event processor. Microsoft.SPOT.EventSink.AddEventProcessor(EventCategory.Touch, new TouchEventProcessor()); /// Start the event sink process. This will pump /// events neatly out of the other world. Microsoft.SPOT.EventSink.AddEventListener(EventCategory.Touch, touchEventListener); /// Also add generic for Gesture stuff. Microsoft.SPOT.EventSink.AddEventListener(EventCategory.Gesture, touchEventListener); _initialized = true; }
public WeakEventListenerWrapper(IEventListener listener) { if (listener.IsWeak) _item = listener; else _item = ToolkitExtensions.GetWeakReference(listener); }
/// <summary> /// Initializes a new instance of the SharedObjectMessage class with given listener, name, version and persistence flag. /// </summary> /// <param name="source">Event listener.</param> /// <param name="name">Event name.</param> /// <param name="version">Shared object version.</param> /// <param name="persistent">Indicates whether shared object is persistent.</param> internal SharedObjectMessage(IEventListener source, string name, int version, bool persistent) : base(EventType.SHARED_OBJECT, Constants.TypeSharedObject, source) { _name = name; _version = version; _persistent = persistent; }
public static void RemoveListener(IEventListener listener) { if (listeners.Contains(listener)) { listeners.Remove(listener); } }
protected override ImporterConverterAbstract GetNext(IEventListener iel, CancellationToken iCancellationToken) { string dp = Path.GetFileName(_FileName); iel.Report(new ExtractProgessEventArgs(dp)); ImporterConverterAbstract next = null; try { IRarDescompactor Sex = Context.RarManager.InstanciateExctractorWithPassword(_FileName, iel); if (Sex == null) { return next; } using (Sex) { if (iCancellationToken.IsCancellationRequested) return null; Sex.DescompactedFiles = _ExtractedFiles; bool res = Sex.Extract(iel, iCancellationToken); _RarFileNames =Sex.ArchiveNames; if (iCancellationToken.IsCancellationRequested) return null; if (res) { NonRecursiveFolderInspector nfr = new NonRecursiveFolderInspector(_IInternalMusicSession,_ExtractedFiles, Sex.Helper, iel); ImporterConverterAbstract[] Importers = nfr.Importers; if (Importers.Length == 0) { iel.Report(new NoMusicImportErrorEventArgs(Sex.Helper.DisplayName)); } else if (Importers.Length > 1) { Trace.WriteLine("Unhandled configuration in a rar file"); iel.Report(new UnhandledRarFile(Sex.Helper.DisplayName)); } else next = Importers[0]; } } } catch(Exception e) { iel.Report(new UnknownRarError(dp)); Trace.WriteLine("Decompressing problem " + e.ToString()); next = null; } return next; }
void ITopWindowEventRoot.RootMouseDown(int x, int y, UIMouseButtons button) { this.prevLogicalMouseX = x; this.prevLogicalMouseY = y; this.isMouseDown = true; this.isDragging = false; UIMouseEventArgs e = GetFreeMouseEvent(); SetUIMouseEventArgsInfo(e, x, y, button, 0); e.PreviousMouseDown = this.latestMouseDown; iTopBoxEventPortal.PortalMouseDown(e); this.currentMouseActiveElement = this.latestMouseDown = e.CurrentContextElement; this.localMouseDownX = e.X; this.localMouseDownY = e.Y; if (e.DraggingElement != null) { if (e.DraggingElement != e.CurrentContextElement) { //change captured element int globalX, globalY; e.DraggingElement.GetGlobalLocation(out globalX, out globalY); //find new capture pos this.localMouseDownX = e.GlobalX - globalX; this.localMouseDownY = e.GlobalY - globalY; } this.draggingElement = e.DraggingElement; } else { this.draggingElement = this.currentMouseActiveElement; } this.mouseCursorStyle = e.MouseCursorStyle; ReleaseMouseEvent(e); }
public void AddEventListener(IEventListener listener) { if (Equals(listener, null)) throw new ArgumentNullException("listener"); Listeners.Add(listener); }
internal NonRecursiveFolderInspector(IInternalMusicSession iIMusicConverter, IEnumerable<string> Files, IImportHelper Clue, IEventListener iel) { _IMusicConverter = iIMusicConverter; _Files = Files; _ClueName = Clue; _IEL = iel; }
public void RemoveListener(IEventListener listener) { try { listerners.Remove(listener); } catch { } }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="eventType"></param> /// <param name="listener"></param> /// <param name="capture"></param> public EventListenerRegistration(string eventType,IEventListener listener, bool capture ) { Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(eventType)); Contract.Requires<ArgumentNullException>(listener != null); this.eventType = eventType; this.listener = listener; this.capture = capture; }
internal FolderInspector(IInternalMusicSession iMusicConverter, DirectoryInfo DI, IEventListener iel) { _IMusicConverter = iMusicConverter; _RootDir = DI; _IEL = iel; string DirName = Path.GetDirectoryName(DI.FullName); _SkipDir = (DirName == null) ? DI.FullName.Length : DirName.Length; _SkipDir++; }
/// <summary> /// Connects an event listener to our message bus /// </summary> /// <param name = "listener">The event listener, which will be marshalled from another AppDomain</param> /// <param name = "context">Run context event raiser</param> /// <remarks> /// We cannot pass the message bus instance to the event listener, since the listener may be in a remote AppDomain /// </remarks> private static void RegisterEventListener(IEventListener listener, IRunContextEvents context) { context.OnRunStarted += (s, e) => listener.RunStarted(); context.OnRunFinished += (s, e) => listener.RunFinished(); context.OnFeatureStarted += (s, e) => listener.FeatureStarted(e.EventInfo); context.OnFeatureFinished += (s, e) => listener.FeatureFinished(e.EventInfo); context.OnScenarioStarted += (s, e) => listener.ScenarioStarted(e.EventInfo.Title); context.OnScenarioFinished += (s, e) => listener.ScenarioFinished(e.EventInfo); }
public static void RemoveListener(EventType type, IEventListener listener) { //no need to do anything if there's no listeners for this type if (!eventListenerMap.ContainsKey(type)) { return; } eventListenerMap[type].Remove(listener); }
public static void RemoveEventFilter(EventCategory eventCategory, IEventListener eventFilter) { EventInfo eventInfo = GetEventInfo(eventCategory); if (eventInfo.EventFilter == eventFilter) { eventInfo.EventFilter = null; } }
public PrimaryListener(IEventListener eventListener) { m_EventListener = eventListener; if (m_EventListener != null) { //EventThread.SetApartmentState(ApartmentState.MTA); EventThread.Priority = ThreadPriority.BelowNormal; EventThread.IsBackground = true; EventThread.Start(this); } }
public static void RemoveListener(int type, IEventListener listener, IEventDispatcher source = null) { if (listeners.ContainsKey(type)) foreach (var l in listeners[type].FindAll(x => ReferenceEquals(x.Listener, listener))) if ((l.DSource == null && source == null) || ReferenceEquals(l.DSource, source)) listeners[type].Remove(l); if (listeners[type].Count == 0) listeners.Remove(type); }
protected override ImporterConverterAbstract GetNext(IEventListener iel, CancellationToken iCancellationToken) { iel.Report(new ImportProgessEventArgs(_NameClue.DisplayName)); List<Track> LocalTrack = GetTracks(iel, iCancellationToken).CancelableToList(iCancellationToken); if (iCancellationToken.IsCancellationRequested) { RawImportEnded(KOEndImport()); return null; } if (LocalTrack.Count == 0) { ImportEnded(); return null; } List<string> Pictures = Images.OrderBy( imp => { string ifn = Path.GetFileNameWithoutExtension(imp).ToLower(); return (ifn.Contains("cover") || ifn.Contains("front"))? 0 : 1; } ).ToList(); foreach (Album Al in (from r in LocalTrack select r.Owner).Distinct<Album>()) { using (IModifiableAlbum AM = Al.GetModifiableAlbum(true, Context)) { if (AM.FrontImage != null) continue; int i = 0; foreach (string apic in Pictures) { IAlbumPicture res = AM.AddAlbumPicture(apic, i); if (res != null) i++; } if (iCancellationToken.IsCancellationRequested) { RawImportEnded(KOEndImport()); return null; } AM.Commit(); } } ImportEnded(); return null; }
public static void AddListener(IEventListener listener) { if (listeners == null) { listeners = new List<IEventListener>(); } if (!listeners.Contains(listener)) { listeners.Add(listener); } }
public bool RegisterListener(IEventListener listener, string eventName) { if (listener == null || eventName == null) { Debug.LogError ("RegisterLisener(): failed due to listener or event == null"); return false; } if (eventListenerMap.ContainsKey (eventName)) { Debug.LogWarning ("Overwriting listener for " + eventName); } // One listener type per event! eventListenerMap [eventName] = listener; return true; }
private void AddListener( IEventListener listener, Type eventType ) { var dlist = new List<IEventListener>(); if ( Listeners.TryGetValue( eventType, out dlist ) ) { if ( !dlist.Contains( listener ) ) dlist.Add( listener ); } else { dlist = new List<IEventListener> {listener}; Listeners.TryAdd( eventType, dlist ); } }
protected override IEnumerable<Track> GetTracks(IEventListener iel, CancellationToken iCancellationToken) { foreach (ITrackDescriptor Mus in _Listtracks) { TrackStatus res = Track.GetTrackFromTrackDescriptor(Mus, true, Context,true); Visit(Mus.Path, res); if ( (res != null) && (res.Continue)) { yield return res.Found; } } }
private void ExtractCallBack(ExtractFileCallbackArgs efc, IEventListener iel, CancellationToken iCancellationToken) { switch (efc.Reason) { case ExtractFileCallbackReason.Start: string nd = null; bool root = false; if (efc.ArchiveFileInfo.FileName == MusicExporter.XMLName) { nd = _ICC.Folders.Temp; root = true; } else { nd = _ICC.Folders.File; } efc.ExtractToFile = FileInternalToolBox.CreateNewAvailableName(Path.Combine(nd, efc.ArchiveFileInfo.FileName)); if (root) _RX = efc.ExtractToFile; else { Directory.CreateDirectory(Path.GetDirectoryName(efc.ExtractToFile)); } if ((!efc.ArchiveFileInfo.IsDirectory) && !(root)) { iel.Report(new ExtractProgessEventArgs(string.Format("{0} from {1}", Path.GetFileName(efc.ArchiveFileInfo.SafePath()), _Sex.FileName))); AddAssociationIfNeeded(efc.ArchiveFileInfo.FileName, efc.ExtractToFile); } DescompactedFiles.Add(efc.ExtractToFile); break; case ExtractFileCallbackReason.Failure: iel.OnFactorisableError<UnableToExtractFileFromRar>(string.Format("{0} from {1} : {2}", Path.GetFileName(efc.ArchiveFileInfo.FileName), _Sex.FileName, efc.Exception)); efc.Exception = null; efc.ExtractToFile = null; _Success = false; break; } if (iCancellationToken.IsCancellationRequested) { _Success = false; efc.CancelExtraction = true; } }
//event queues? public static void AddListener(EventType type, IEventListener listener) { //build the listener list if it doesn't exist yet if (!eventListenerMap.ContainsKey(type)) { eventListenerMap[type] = new List<IEventListener>(); } List<IEventListener> listenerList = eventListenerMap[type]; //ensure this listener's not already subscribed if (!listenerList.Contains(listener)) { //now add the listener listenerList.Add(listener); } }
public static Task Signal(this IEventListener instance, string id, Func <EventData> createMessage) => instance.Signal(id, instance.Token, createMessage);
public static Task Signal(this IEventListener instance, string id, HttpResponseMessage response) => instance.Signal(id, instance.Token, () => new EventData { Id = id, RequestMessage = response.RequestMessage, ResponseMessage = response, Cancel = instance.Cancel });
/// <summary> /// The method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events. /// </summary> /// <param name="type">A string representing the event type to listen for.</param> /// <param name="listener">The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.</param> public virtual void AddEventListener(string type, IEventListener listener) { }
/// <summary> /// Removes the event listener previously registered with EventTarget.addEventListener. /// </summary> /// <param name="type">A string representing the event type being removed.</param> /// <param name="listener">The listener parameter indicates the EventListener function to be removed.</param> public virtual void RemoveEventListener(EventType type, IEventListener listener) { }
/// <summary> /// Removes the event listener previously registered with EventTarget.addEventListener. /// </summary> /// <param name="type">A string representing the event type being removed.</param> /// <param name="listener">The listener parameter indicates the EventListener function to be removed.</param> public virtual void RemoveEventListener(string type, IEventListener listener) { }
public EventsFormatterData(IEventListener <FormatChanged> formatChangedListener) { _formatChangedListener = formatChangedListener; _timeFormat = TimeStampFormat.Absolute; HiddenMessages = new List <string>(); }
public static Task Signal(this IEventListener instance, string id, System.Uri uri) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = uri.ToString(), Cancel = instance.Cancel });
public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, Cancel = instance.Cancel });
/// <summary> /// The method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events. /// </summary> /// <param name="type">A string representing the event type to listen for.</param> /// <param name="listener">The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.</param> public virtual void AddEventListener(EventType type, IEventListener listener) { }
/// <summary> /// The method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events. /// </summary> /// <param name="type">A string representing the event type to listen for.</param> /// <param name="listener">The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.</param> /// <param name="useCapture"></param> public virtual void AddEventListener(string type, IEventListener listener, bool useCapture) { }
public static Task Signal(this IEventListener instance, string id) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Cancel = instance.Cancel });
public Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, IEventListener callback) => implementation(request, callback, next);
public async Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, IEventListener callback, ISendAsync next) { counter++; var rqkey = $"{Description}+{Context}+{Scenario}+${request.Method.Method}+{request.RequestUri}+{counter}"; switch (Mode) { case MockMode.Record: //Add following code since the request.Content will be released after sendAsync var requestClone = request; if (requestClone.Content != null) { requestClone = await request.CloneWithContent(request.RequestUri, request.Method); } // make the call var response = await next.SendAsync(request, callback); // save the message to the recording file SaveMessage(rqkey, requestClone, response); // return the response. return(response); case MockMode.Playback: // load and return the response. return(LoadMessage(rqkey)); default: // pass-thru, do nothing return(await next.SendAsync(request, callback)); } }
/// <summary> /// Removes the event listener previously registered with EventTarget.addEventListener. /// </summary> /// <param name="type">A string representing the event type being removed.</param> /// <param name="listener">The listener parameter indicates the EventListener function to be removed.</param> /// <param name="capture">Specifies whether the EventListener being removed was registered as a capturing listener or not. If not specified, useCapture defaults to false.</param> public virtual void RemoveEventListener(string type, IEventListener listener, bool capture) { }
public static async Task AssertObjectIsValid(this IEventListener instance, string parameterName, object inst) { await(inst as Microsoft.Rest.ClientRuntime.IValidates)?.Validate(instance); }
public void AddEventListener(MenuItemElementEvents type, IEventListener listener, bool capture) { }
public static Task Signal(this IEventListener instance, string id, string messageText, double magnitude, HttpResponseMessage response) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, RequestMessage = response.RequestMessage, ResponseMessage = response, Value = magnitude, Cancel = instance.Cancel });
public void RemoveEventListener(MenuItemElementEvents type, IEventListener listener) { }
public static async Task AssertObjectIsValid(this IEventListener instance, string parameterName, object inst) { await(inst as Microsoft.Azure.PowerShell.Cmdlets.ManagedServiceIdentity.Runtime.IValidates)?.Validate(instance); }
public void BeginUpdate(IEventListener listener) { _source = listener; // Increase number of pending updates _updateCounter.Increment(); }
public static Task Signal(this IEventListener instance, string id, string messageText, double magnitude) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, Value = magnitude, Cancel = instance.Cancel });
/// <summary> /// Removes the event listener previously registered with EventTarget.addEventListener. /// </summary> /// <param name="type">A string representing the event type being removed.</param> /// <param name="listener">The listener parameter indicates the EventListener function to be removed.</param> /// <param name="capture">Specifies whether the EventListener being removed was registered as a capturing listener or not. If not specified, useCapture defaults to false.</param> public virtual void RemoveEventListener(EventType type, IEventListener listener, bool capture) { }
public static Task Signal(this IEventListener instance, string id, CancellationToken token, HttpRequestMessage request) => instance.Signal(id, token, () => new EventData { Id = id, RequestMessage = request, Cancel = instance.Cancel });
public static Task Signal(this IEventListener instance, string id, CancellationToken token, string messageText, double magnitude, HttpRequestMessage request) => instance.Signal(id, token, () => new EventData { Id = id, Message = messageText, RequestMessage = request, Value = magnitude, Cancel = instance.Cancel });
public virtual void Unregister(IEventListener listener) { _listeners.Remove(listener); CheckRelease(); }
/// <summary> /// The method registers the specified listener on the EventTarget it's called on. The event target may be an Element in a document, the Document itself, a Window, or any other object that supports events. /// </summary> /// <param name="type">A string representing the event type to listen for.</param> /// <param name="listener">The object that receives a notification when an event of the specified type occurs. This must be an object implementing the EventListener interface, or simply a JavaScript function.</param> /// <param name="useCapture"></param> public virtual void AddEventListener(EventType type, IEventListener listener, bool useCapture) { }
public void AddEventListener(MenuItemElementEvents type, IEventListener listener) { }
public static Task Signal(this IEventListener instance, string id, CancellationToken token, EventData message) => instance.Signal(id, token, () => { message.Id = id; message.Cancel = instance.Cancel; return(message); });
public void Remove(IEventListener listener) { subscribersLock.Enter(); subscribers.Remove(listener); subscribersLock.Exit(); }
public static Task Signal(this IEventListener instance, string id, string messageText, HttpRequestMessage request) => instance.Signal(id, instance.Token, () => new EventData { Id = id, Message = messageText, RequestMessage = request, Cancel = instance.Cancel });