protected void dispatchPreChangeEvent(CollectionEventKind kind, object items, int startIndex, int endIndex) { if (OnCollectionPreChange != null) { OnCollectionPreChange(kind, this, items, startIndex, endIndex); } }
private void InternalDispatchEvent(CollectionEventKind kind, object item /* = null*/, int location /* = -1*/) { // copied from ArrayList //Debug.Log(string.Format("InternalDispatchEvent: {0}, {1}, {2}", kind, item, location)); if (HasEventListener(CollectionEvent.COLLECTION_CHANGE)) { var ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE) { Kind = kind }; ce.Items.Add(item); ce.Location = location; DispatchEvent(ce); } // now dispatch a complementary PropertyChangeEvent if (HasEventListener(PropertyChangeEvent.PROPERTY_CHANGE) && (kind == CollectionEventKind.ADD || kind == CollectionEventKind.REMOVE)) { var objEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE) { Property = location.ToString() }; if (kind == CollectionEventKind.ADD) { objEvent.NewValue = item; } else { objEvent.OldValue = item; } DispatchEvent(objEvent); } }
/// <summary> /// Dispatches a collection event with the specified information. /// </summary> /// <param name="kind"></param> /// <param name="item"></param> /// <param name="location"></param> private void InternalDispatchEvent(CollectionEventKind kind, object item = null, int location= -1) { //Debug.Log(string.Format("InternalDispatchEvent: {0}, {1}, {2}", kind, item, location)); if (_dispatchEvents == 0) { if (HasEventListener(CollectionEvent.COLLECTION_CHANGE)) { var ce = new CollectionEvent(CollectionEvent.COLLECTION_CHANGE) { Kind = kind }; ce.Items.Add(item); ce.Location = location; DispatchEvent(ce); } // now dispatch a complementary PropertyChangeEvent if (HasEventListener(PropertyChangeEvent.PROPERTY_CHANGE) && (kind == CollectionEventKind.ADD || kind == CollectionEventKind.REMOVE)) { var objEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE) {Property = location.ToString()}; if (kind == CollectionEventKind.ADD) objEvent.NewValue = item; else objEvent.OldValue = item; DispatchEvent(objEvent); } } }