9using System.ComponentModel;
11#if NETFX_CORE || (ANDROID || IOS)
12using System.Collections.Generic;
13using System.Collections.Specialized;
32 private EventHandler<RemovingItemEventArgs> _nonSerializableHandlers;
33 private EventHandler<RemovingItemEventArgs> _serializableHandlers;
42 if (value.Method.IsPublic &&
43 (value.Method.DeclaringType.IsSerializable ||
44 value.Method.IsStatic))
45 _serializableHandlers = (EventHandler<RemovingItemEventArgs>)
46 System.Delegate.Combine(_serializableHandlers, value);
48 _nonSerializableHandlers = (EventHandler<RemovingItemEventArgs>)
49 System.Delegate.Combine(_nonSerializableHandlers, value);
53 if (value.Method.IsPublic &&
54 (value.Method.DeclaringType.IsSerializable ||
55 value.Method.IsStatic))
56 _serializableHandlers = (EventHandler<RemovingItemEventArgs>)
57 System.Delegate.Remove(_serializableHandlers, value);
59 _nonSerializableHandlers = (EventHandler<RemovingItemEventArgs>)
60 System.Delegate.Remove(_nonSerializableHandlers, value);
71 [EditorBrowsable(EditorBrowsableState.Advanced)]
74 if (_nonSerializableHandlers !=
null)
75 _nonSerializableHandlers.Invoke(
this,
77 if (_serializableHandlers !=
null)
78 _serializableHandlers.Invoke(
this,
94 base.RemoveItem(index);
101 public void AddRange(System.Collections.Generic.IEnumerable<T> range)
103 foreach (var element
in range)
128 if (_busyChanged !=
null)
129 _busyChanged(
this, args);
146 [System.ComponentModel.DataAnnotations.Display(AutoGenerateField =
false)]
147 [System.ComponentModel.DataAnnotations.ScaffoldColumn(
false)]
150 get {
throw new NotImplementedException(); }
157 [System.ComponentModel.DataAnnotations.Display(AutoGenerateField =
false)]
158 [System.ComponentModel.DataAnnotations.ScaffoldColumn(
false)]
171 private EventHandler<ErrorEventArgs> _unhandledAsyncException;
179 add { _unhandledAsyncException = (EventHandler<ErrorEventArgs>)Delegate.Combine(_unhandledAsyncException, value); }
180 remove { _unhandledAsyncException = (EventHandler<ErrorEventArgs>)Delegate.Remove(_unhandledAsyncException, value); }
190 if (_unhandledAsyncException !=
null)
191 _unhandledAsyncException(
this, error);
204 void unhandled_UnhandledAsyncException(
object sender,
ErrorEventArgs e)
216 base.InsertItem(index, item);
225 [EditorBrowsable(EditorBrowsableState.Never)]
233 if (unhandled !=
null)
236 INotifyPropertyChanged c = item as INotifyPropertyChanged;
250 [EditorBrowsable(EditorBrowsableState.Never)]
258 if (unhandled !=
null)
261 INotifyPropertyChanged c = item as INotifyPropertyChanged;
267 child.
ChildChanged -=
new EventHandler<ChildChangedEventArgs>(Child_Changed);
274 [EditorBrowsable(EditorBrowsableState.Advanced)]
289 [System.Runtime.Serialization.OnDeserialized]
290 private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext context)
292 foreach (T item
in this)
310 System.Delegate.Combine(_childChangedHandlers, value);
315 System.Delegate.Remove(_childChangedHandlers, value);
326 [EditorBrowsable(EditorBrowsableState.Advanced)]
329 if (_childChangedHandlers !=
null)
330 _childChangedHandlers.Invoke(
this, e);
333#if NETFX_CORE || (ANDROID || IOS)
338 private void RaiseChildChanged(
339 object childObject, PropertyChangedEventArgs propertyArgs, NotifyCollectionChangedEventArgs listArgs)
350 [EditorBrowsable(EditorBrowsableState.Never)]
353 RaiseChildChanged(sender, e,
null);
361 private void Child_Changed(
object sender, ChildChangedEventArgs e)
363 RaiseChildChanged(e.ChildObject, e.PropertyChangedArgs, e.CollectionChangedArgs);
369 private void RaiseChildChanged(
370 object childObject, PropertyChangedEventArgs propertyArgs, ListChangedEventArgs listArgs)
372 ChildChangedEventArgs args =
new ChildChangedEventArgs(childObject, propertyArgs, listArgs);
383 [EditorBrowsable(EditorBrowsableState.Never)]
386 RaiseChildChanged(sender, e,
null);
406 get {
return new SuppressListChangedEventsClass<T>(
this); }
414 class SuppressListChangedEventsClass<TC> : IDisposable
416 private readonly BindingList<TC> _businessObject;
417 private readonly
bool _initialRaiseListChangedEvents;
419 public SuppressListChangedEventsClass(BindingList<TC> businessObject)
421 this._businessObject = businessObject;
422 _initialRaiseListChangedEvents = businessObject.RaiseListChangedEvents;
423 businessObject.RaiseListChangedEvents =
false;
426 public void Dispose()
428 _businessObject.RaiseListChangedEvents = _initialRaiseListChangedEvents;
Event arguments for the BusyChanged event.
Contains event data about the changed child object.
PropertyChangedEventArgs PropertyChangedArgs
Gets the PropertyChangedEventArgs object from the child's PropertyChanged event, if the child is not ...
object ChildObject
Gets a reference to the changed child object.
ListChangedEventArgs ListChangedArgs
Gets the ListChangedEventArgs object from the child's ListChanged event, if the child is a collection...
Event arguments for an unhandled async exception.
Extends BindingList of T by adding extra behaviors.
virtual void OnDeserialized()
This method is called on a newly deserialized object after deserialization is complete.
IDisposable SuppressListChangedEvents
Use this object to suppress ListChangedEvents for an entire code block.
void OnRemovingItem(T removedItem)
Raise the RemovingItem event.
virtual void OnUnhandledAsyncException(ErrorEventArgs error)
Method invoked when an unhandled async exception has occurred.
override void InsertItem(int index, T item)
Invoked when an item is inserted into the list.
void OnBusyChanged(string propertyName, bool busy)
Raises the BusyChanged event for a specific property.
BusyChangedEventHandler BusyChanged
Event indicating that the busy status of the object has changed.
virtual bool IsSelfBusy
Gets the busy status for this object.
EventHandler< Csla.Core.ChildChangedEventArgs > ChildChanged
Event raised when a child object has been changed.
virtual void Child_PropertyChanged(object sender, PropertyChangedEventArgs e)
Handles any PropertyChanged event from a child object and echoes it up as a ChildChanged event.
virtual bool IsBusy
Gets the busy status for this object and its child objects.
EventHandler< RemovingItemEventArgs > RemovingItem
Implements a serialization-safe RemovingItem event.
override void RemoveItem(int index)
Remove the item at the specified index.
virtual void OnAddEventHooks(T item)
Method invoked when events are hooked for a child object.
virtual void OnChildChanged(ChildChangedEventArgs e)
Raises the ChildChanged event, indicating that a child object has been changed.
virtual void OnBusyChanged(BusyChangedEventArgs args)
Override this method to be notified when the IsBusy property has changed.
virtual void OnRemoveEventHooks(T item)
Method invoked when events are unhooked for a child object.
void OnUnhandledAsyncException(object originalSender, Exception error)
Raises the UnhandledAsyncException event.
EventHandler< ErrorEventArgs > UnhandledAsyncException
Event indicating that an exception occurred during an async operation.
void AddRange(System.Collections.Generic.IEnumerable< T > range)
Add a range of items to the list.
Inherit from this base class to easily create a serializable list class.
Contains event data for the RemovingItem event.
Extends IBindingList by adding extra events.
Interface defining an object that notifies when it is busy executing an asynchronous operation.
BusyChangedEventHandler BusyChanged
Event raised when the object's busy status changes.
Implemented by classes that notify when a child object has changed.
EventHandler< ChildChangedEventArgs > ChildChanged
Event indictating that a child object has changed.
Implemented by an object that perfoms asynchronous operations that may raise exceptions.
EventHandler< ErrorEventArgs > UnhandledAsyncException
Event indicating that an exception occurred during an asynchronous operation.
Extension of IMobileObject for list types
Interface defining callback methods used by the SerializationFormatterFactory.GetFormatter().
void Deserialized()
Method called on an object after deserialization is complete.
delegate void BusyChangedEventHandler(object sender, BusyChangedEventArgs e)
Delegate for handling the BusyChanged event.
@ Serializable
Prevents updating or inserting until the transaction is complete.