9using System.ComponentModel;
10using System.Collections.Generic;
13using System.Reflection;
17using System.Collections.ObjectModel;
18using System.Collections.Specialized;
19using System.ComponentModel.DataAnnotations;
21using System.Diagnostics;
37 #region SupportsChangeNotification
39 private bool _supportsChangeNotificationCore =
true;
50 private bool _raiseListChangedEvents =
true;
58 get {
return _allowEdit; }
59 protected set { _allowEdit = value; }
68 get {
return _allowNew; }
69 protected set { _allowNew = value; }
78 get {
return _allowRemove; }
79 protected set { _allowRemove = value; }
88 get {
return _raiseListChangedEvents; }
89 set { _raiseListChangedEvents = value; }
109 #region RemovingItem event
112 private EventHandler<RemovingItemEventArgs> _removingItemHandler;
121 _removingItemHandler = (EventHandler<RemovingItemEventArgs>)
122 System.Delegate.Combine(_removingItemHandler, value);
126 _removingItemHandler = (EventHandler<RemovingItemEventArgs>)
127 System.Delegate.Remove(_removingItemHandler, value);
138 [EditorBrowsable(EditorBrowsableState.Advanced)]
141 if (_removingItemHandler !=
null)
142 _removingItemHandler.Invoke(
this,
162 base.RemoveItem(index);
173 public void AddRange(System.Collections.Generic.IEnumerable<T> range)
175 foreach (var element
in range)
181 #region INotifyPropertyBusy Members
204 if (_busyChanged !=
null)
205 _busyChanged(
this, args);
222 [Display(AutoGenerateField =
false)]
223 [ScaffoldColumn(
false)]
226 get {
return false; }
233 [Display(AutoGenerateField =
false)]
234 [ScaffoldColumn(
false)]
247 #region INotifyUnhandledAsyncException Members
251 private EventHandler<ErrorEventArgs> _unhandledAsyncException;
259 add { _unhandledAsyncException = (EventHandler<ErrorEventArgs>)Delegate.Combine(_unhandledAsyncException, value); }
260 remove { _unhandledAsyncException = (EventHandler<ErrorEventArgs>)Delegate.Remove(_unhandledAsyncException, value); }
270 if (_unhandledAsyncException !=
null)
271 _unhandledAsyncException(
this, error);
284 void unhandled_UnhandledAsyncException(
object sender,
ErrorEventArgs e)
291 #region AddChildHooks
300 base.InsertItem(index, item);
309 [EditorBrowsable(EditorBrowsableState.Never)]
317 if (unhandled !=
null)
320 INotifyPropertyChanged c = item as INotifyPropertyChanged;
338 [EditorBrowsable(EditorBrowsableState.Never)]
346 if (unhandled !=
null)
349 INotifyPropertyChanged c = item as INotifyPropertyChanged;
359 child.
ChildChanged -=
new EventHandler<ChildChangedEventArgs>(Child_Changed);
364 #region ISerializationNotification Members
370 [EditorBrowsable(EditorBrowsableState.Advanced)]
377 [System.Runtime.Serialization.OnDeserialized]
378 private void OnDeserializedHandler(System.Runtime.Serialization.StreamingContext context)
380 foreach (T item
in this)
396 #region Child Change Notification
410 System.Delegate.Combine(_childChangedHandlers, value);
415 System.Delegate.Remove(_childChangedHandlers, value);
426 [EditorBrowsable(EditorBrowsableState.Advanced)]
429 if (_childChangedHandlers !=
null)
430 _childChangedHandlers.Invoke(
this, e);
436 private void RaiseChildChanged(
437 object childObject, PropertyChangedEventArgs propertyArgs, NotifyCollectionChangedEventArgs listArgs)
450 [EditorBrowsable(EditorBrowsableState.Never)]
458 RaiseChildChanged(sender, e,
null);
478 private EventHandler<AddedNewEventArgs<T>> _addedNewHandlers =
null;
480 private bool _allowEdit;
481 private bool _allowNew;
482 private bool _allowRemove;
488 public event EventHandler<AddedNewEventArgs<T>>
AddedNew
492 _addedNewHandlers = (EventHandler<AddedNewEventArgs<T>>)
493 System.Delegate.Combine(_addedNewHandlers, value);
497 _addedNewHandlers = (EventHandler<AddedNewEventArgs<T>>)
498 System.Delegate.Remove(_addedNewHandlers, value);
506 [EditorBrowsable(EditorBrowsableState.Advanced)]
509 if (_addedNewHandlers !=
null)
512 _addedNewHandlers(
this, args);
516#if (ANDROID || IOS) || NETFX_CORE
538 #region OnCollectionChanged
544 [EditorBrowsable(EditorBrowsableState.Advanced)]
548 base.OnCollectionChanged(e);
560 [EditorBrowsable(EditorBrowsableState.Advanced)]
563 base.OnGetState(info);
568 info.
AddValue(
"Csla.Core.MobileList._supportsChangeNotificationCore", _supportsChangeNotificationCore);
576 [EditorBrowsable(EditorBrowsableState.Advanced)]
579 base.OnSetState(info);
580 AllowEdit = info.GetValue<
bool>(
"Csla.Core.MobileList.AllowEdit");
581 AllowNew = info.GetValue<
bool>(
"Csla.Core.MobileList.AllowNew");
582 AllowRemove = info.GetValue<
bool>(
"Csla.Core.MobileList.AllowRemove");
584 _supportsChangeNotificationCore = info.GetValue<
bool>(
"Csla.Core.MobileList._supportsChangeNotificationCore");
589 #region SuppressLListChanged
597 get {
return new SuppressListChangedEventsClass<T>(
this); }
605 class SuppressListChangedEventsClass<TC> : IDisposable
608 private readonly
bool _initialRaiseListChangedEvents;
612 this._businessObject = businessObject;
617 public void Dispose()
619 _businessObject.RaiseListChangedEvents = _initialRaiseListChangedEvents;
627 private Stack<bool> _oldRLCE;
635 if (_oldRLCE ==
null)
636 _oldRLCE =
new Stack<bool>();
639 _oldRLCE.Push(_raiseListChangedEvents);
640 _raiseListChangedEvents =
false;
644 if (_oldRLCE.Count > 0)
645 _raiseListChangedEvents = _oldRLCE.Pop();
Object containing information about a newly added object.
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.
NotifyCollectionChangedEventArgs CollectionChangedArgs
Gets the NotifyCollectionChangedEventArgs object from the child's CollectionChanged event,...
Event arguments for an unhandled async exception.
Inherit from this base class to easily create a serializable list class.
Extends ObservableCollection with behaviors required by CSLA .NET collections.
virtual bool IsBusy
Gets the busy status for this object and its child objects.
bool AllowRemove
Gets or sets a value indicating whether data binding can automatically remove items from this collect...
void OnBusyChanged(string propertyName, bool busy)
Raises the BusyChanged event for a specific property.
override void OnGetState(SerializationInfo info)
Override this method to get custom field values from the serialization stream.
override void RemoveItem(int index)
Remove the item at the specified index.
bool AllowEdit
Gets or sets a value indicating whether data binding can automatically edit items in this collection.
EventHandler< AddedNewEventArgs< T > > AddedNew
Event raised when a new object has been added to the collection.
override void OnSetState(SerializationInfo info)
Override this method to set custom field values into the serialization stream.
IDisposable SuppressListChangedEvents
Use this object to suppress ListChangedEvents for an entire code block.
virtual void OnRemoveEventHooks(T item)
Method invoked when events are unhooked for a child object.
virtual void OnAddEventHooks(T item)
Method invoked when events are hooked for a child object.
virtual bool IsSelfBusy
Gets the busy status for this object.
BusyChangedEventHandler BusyChanged
Event indicating that the busy status of the object has changed.
void OnUnhandledAsyncException(object originalSender, Exception error)
Raises the UnhandledAsyncException event.
virtual void OnBusyChanged(BusyChangedEventArgs args)
Override this method to be notified when the IsBusy property has changed.
virtual void OnChildChanged(ChildChangedEventArgs e)
Raises the ChildChanged event, indicating that a child object has been changed.
virtual bool SupportsChangeNotificationCore
Gets a value indicating whether this object supports change notification.
virtual void OnDeserialized()
This method is called on a newly deserialized object after deserialization is complete.
bool AllowNew
Gets or sets a value indicating whether data binding can automatically add new items to this collecti...
virtual T AddNewCore()
Override this method to create a new object that is added to the collection.
virtual void Child_PropertyChanged(object sender, PropertyChangedEventArgs e)
Handles any PropertyChanged event from a child object and echoes it up as a ChildChanged event.
override void InsertItem(int index, T item)
Invoked when an item is inserted into the list.
override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
Raises the CollectionChanged event.
virtual void OnAddedNew(T item)
Raises the AddedNew event.
void AddRange(System.Collections.Generic.IEnumerable< T > range)
Add a range of items to the list.
override void SetLoadListMode(bool enabled)
Sets the load list mode for the list
virtual void OnUnhandledAsyncException(ErrorEventArgs error)
Method invoked when an unhandled async exception has occurred.
void OnRemovingItem(T removedItem)
Raise the RemovingItem event.
T AddNew()
Adds a new item to this collection.
EventHandler< Csla.Core.ChildChangedEventArgs > ChildChanged
Event raised when a child object has been changed.
EventHandler< RemovingItemEventArgs > RemovingItem
Implements a serialization-safe RemovingItem event.
EventHandler< ErrorEventArgs > UnhandledAsyncException
Event indicating that an exception occurred during an async operation.
bool RaiseListChangedEvents
Gets or sets a value indicating whether the collection should raise changed events.
Contains event data for the RemovingItem event.
A strongly-typed resource class, for looking up localized strings, etc.
static string AddNewCoreMustBeOverriden
Looks up a localized string similar to AddNewCore must be overridden.
Object containing the serialization data for a specific object.
void AddValue(string name, object value)
Adds a value to the serialization stream.
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.
Defines additional elements for an ObservableCollection as required by CSLA .NET.
object AddNew()
Creates and adds a new item to the collection.
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.