private void OnPropertyChanging( TListener listener, object subject, object rootSubject, PropertyChangingEventArgs args) { UnsubscribeFromChildren(listener, subject, rootSubject); }
public void Unsubscribe( INotifyPropertyChanged subject, object rootSubject, TListener listener) { WeakPropertyChangedEventManager.Unregister(subject, _propertyAccessNode.PropertyName, listener, rootSubject); UnsubscribeFromChildren(listener, subject, rootSubject); }
private void OnPropertyChanged( TListener listener, object subject, object rootSubject, PropertyChangedEventArgs args) { SubscribeToChildren(listener, subject, rootSubject); _subscriberCallback(listener, rootSubject); }
private void OnPropertyChanging( TListener listener, object subject, object rootSubject, PropertyChangingEventArgs args) { UnsubscribeFromChildren(listener, subject, rootSubject); if (_subscriberChangingCallback != null) { _subscriberChangingCallback(listener, rootSubject, args); } }
public void ListenerResultReceived(object sender, MsgEvent result) { lock (ListenerLock) { TListener viewResultListener = ResultListener; if (viewResultListener == null) { return; } _action(result.Msg, viewResultListener); // Needs to be done in the lock to maintain order } }
public void Subscribe( INotifyPropertyChanged subject, object rootSubject, TListener listener) { WeakPropertyChangedEventManager.Register( subject, rootSubject, _propertyAccessNode.PropertyName, listener, _onChangingCallback, _onChangedCallback); SubscribeToChildren(listener, subject, rootSubject); }
public void Unsubscribe(INotifyPropertyChanged subject, TListener listener) { INotifyPropertyChanged subjectToUnsubscribe = subject; ConstantNode constantNode = _propertyAccessTreeNode as ConstantNode; if (constantNode != null) { subjectToUnsubscribe = constantNode.Value; } for (int i = 0; i < _children.Count; i++) { _children[i].Unsubscribe(subjectToUnsubscribe, subject, listener); } }
public void Subscribe(INotifyPropertyChanged subject, TListener listener) { INotifyPropertyChanged subjectToSubscribe = subject; ConstantNode constantNode = _propertyAccessTreeNode as ConstantNode; if (constantNode != null) { subjectToSubscribe = constantNode.Value; } foreach (var child in _children) { child.Subscribe(subjectToSubscribe, subject, listener); } }
/// <summary> /// 注册监听器 在监听器类的Start函数调用 /// </summary> /// <param name="Event_Type">监听的事件</param> /// <param name="Listener">事件的监听器</param> public void AddListener(EVENT_TYPE Event_Type, TListener Listener) { List <TListener> ListenList = null; //如果当前事件的监听器不为空 则直接添加监听器至链表 if (Listeners.TryGetValue(Event_Type, out ListenList)) { ListenList.Add(Listener); } //如果当前事件的监听器为空 则新建链表 添加键值对 else { ListenList = new List <TListener>(); ListenList.Add(Listener); Listeners.Add(Event_Type, ListenList); } }
private void UnsubscribeFromChildren(TListener listener, object subject, object rootSubject) { if (_children.Count == 0) { return; } INotifyPropertyChanged oldChildSubject = (INotifyPropertyChanged)_propertyAccessNode.GetPropertyValue(subject); if (oldChildSubject == null) { return; } for (int i = 0; i < _children.Count; i++) { _children[i].Unsubscribe(oldChildSubject, rootSubject, listener); } }
private void UnsubscribeFromChildren(TListener listener, object subject, object rootSubject) { if (_children.Count == 0) { return; } INotifyPropertyChanged oldChildSubject = (INotifyPropertyChanged)_propertyAccessNode.GetPropertyValue(subject); if (oldChildSubject == null) { return; } foreach (SubscriptionNode t in _children) { t.Unsubscribe(oldChildSubject, rootSubject, listener); } }
protected void InspectorGUI <TListener, TData>() where TData : XUEventListenerData, new() where TListener : XUEventListener <TData> { // 更新显示 this.serializedObject.Update(); // 自定义绘制 TListener listener = target as TListener; foreach (EventTriggerType triggerType in Enum.GetValues(typeof(EventTriggerType))) { string strEvent = ""; object objParam = null; listener.GetEvent(triggerType, out strEvent, out objParam); if (string.IsNullOrEmpty(strEvent)) { continue; } if (foldoutMap.ContainsKey(triggerType) == false) { foldoutMap.Add(triggerType, true); } foldoutMap[triggerType] = EditorGUILayout.Foldout(foldoutMap[triggerType], "事件类型:" + triggerType.ToString()); if (foldoutMap[triggerType]) { string strEventNew = EditorGUILayout.TextField("事件名称:", strEvent); object objParamNew = DrawObject("事件参数", objParam); if (strEventNew != strEvent || objParamNew != objParam) { listener.SetEvent(triggerType, strEventNew, objParamNew); } } } // 应用属性修改 this.serializedObject.ApplyModifiedProperties(); }
public void Stop() { _listener.Dispose(); _listener = null; this.Dispose(); }