CSLA.NET 6.0.0
CSLA .NET is a software development framework that helps you build a reusable, maintainable object-oriented business layer for your app.
Csla.DynamicListBase< T > Class Template Reference

This is the base class from which collections of editable root business objects should be derived. More...

Inheritance diagram for Csla.DynamicListBase< T >:
Csla.Core.ObservableBindingList< T > Csla.Core.IParent Csla.Serialization.Mobile.ISerializationNotification Csla.Core.IBusinessObject Csla.Core.IUseApplicationContext Csla.Core.MobileObservableCollection< T > Csla.Core.IObservableBindingList Csla.Core.INotifyBusy Csla.Core.INotifyChildChanged Csla.Serialization.Mobile.ISerializationNotification Csla.Serialization.Mobile.IMobileList Csla.Core.INotifyUnhandledAsyncException Csla.Serialization.Mobile.IMobileObject

Public Member Functions

 DynamicListBase ()
 Creates an instance of the type. More...
 
async Task SaveItemAsync (T item)
 Saves the specified item in the list. More...
 
async Task SaveItemAsync (int index)
 Saves the specified item in the list. More...
 
void SaveItem (T item)
 Saves the specified item in the list. More...
 
async void SaveItem (int index)
 Saves the specified item in the list. More...
 
T[] ToArray ()
 Get an array containing all items in the list. More...
 
- Public Member Functions inherited from Csla.Core.ObservableBindingList< T >
AddNew ()
 Adds a new item to this collection. More...
 
void AddRange (System.Collections.Generic.IEnumerable< T > range)
 Add a range of items to the list. More...
 
virtual void OnAddedNew (T item)
 Raises the AddedNew event. More...
 

Protected Member Functions

virtual void Initialize ()
 Override this method to set up event handlers so user code in a partial class can respond to events raised by generated code. More...
 
virtual void OnSaved (T newObject, Exception error)
 Raises the Saved event. More...
 
virtual async Task SaveItemAsync (int index, bool delete)
 Saves the specified item in the list. More...
 
override T AddNewCore ()
 Adds a new item to the list. More...
 
override void InsertItem (int index, T item)
 Gives the new object a parent reference to this list. More...
 
override async void RemoveItem (int index)
 Removes an item from the list. More...
 
override void SetItem (int index, T item)
 Replaces item in the list. More...
 
override void OnCollectionChanged (NotifyCollectionChangedEventArgs e)
 Raises the CollectionChanged event. More...
 
override void OnDeserialized ()
 Set parent reference. More...
 
virtual void DataPortal_OnDataPortalInvoke (DataPortalEventArgs e)
 Called by the server-side DataPortal prior to calling the requested DataPortal_xyz method. More...
 
virtual void DataPortal_OnDataPortalInvokeComplete (DataPortalEventArgs e)
 Called by the server-side DataPortal after calling the requested DataPortal_xyz method. More...
 
virtual void DataPortal_OnDataPortalException (DataPortalEventArgs e, Exception ex)
 Called by the server-side DataPortal if an exception occurs during data access. More...
 
override void OnGetState (SerializationInfo info)
 Override this method to insert your field values into the MobileFormatter serialzation stream. More...
 
override void OnSetState (SerializationInfo info)
 Override this method to retrieve your field values from the MobileFormatter serialzation stream. More...
 
- Protected Member Functions inherited from Csla.Core.ObservableBindingList< T >
void OnRemovingItem (T removedItem)
 Raise the RemovingItem event. More...
 
override void RemoveItem (int index)
 Remove the item at the specified index. More...
 
virtual void OnBusyChanged (BusyChangedEventArgs args)
 Override this method to be notified when the IsBusy property has changed. More...
 
void OnBusyChanged (string propertyName, bool busy)
 Raises the BusyChanged event for a specific property. More...
 
virtual void OnUnhandledAsyncException (ErrorEventArgs error)
 Method invoked when an unhandled async exception has occurred. More...
 
void OnUnhandledAsyncException (object originalSender, Exception error)
 Raises the UnhandledAsyncException event. More...
 
override void InsertItem (int index, T item)
 Invoked when an item is inserted into the list. More...
 
virtual void OnAddEventHooks (T item)
 Method invoked when events are hooked for a child object. More...
 
virtual void OnRemoveEventHooks (T item)
 Method invoked when events are unhooked for a child object. More...
 
virtual void OnChildChanged (ChildChangedEventArgs e)
 Raises the ChildChanged event, indicating that a child object has been changed. More...
 
virtual void Child_PropertyChanged (object sender, PropertyChangedEventArgs e)
 Handles any PropertyChanged event from a child object and echoes it up as a ChildChanged event. More...
 
override void OnCollectionChanged (NotifyCollectionChangedEventArgs e)
 Raises the CollectionChanged event. More...
 
override void SetLoadListMode (bool enabled)
 Sets the load list mode for the list More...
 
- Protected Member Functions inherited from Csla.Core.MobileObservableCollection< T >
virtual void OnGetChildren (SerializationInfo info, MobileFormatter formatter)
 Override this method to get custom child object values from the serialization stream. More...
 
virtual void OnSetChildren (SerializationInfo info, MobileFormatter formatter)
 Override this method to set custom child object values into the serialization stream. More...
 

Properties

ApplicationContext ApplicationContext [get]
 Gets the current ApplicationContext More...
 
bool RaiseReplaceEvents [getset]
 Gets or sets a value indicating whether the Replace event should be raised when OnCollectionChanged() is called. More...
 
override bool SupportsChangeNotificationCore [get]
 Gets a value indicating whether this collection supports change notification (always returns true). More...
 
override bool IsBusy [get]
 Gets a value indicating whether this object or any child object is currently executing an async operation. More...
 
- Properties inherited from Csla.Core.ObservableBindingList< T >
virtual bool SupportsChangeNotificationCore [get]
 Gets a value indicating whether this object supports change notification. More...
 
bool AllowEdit [getprotected set]
 Gets or sets a value indicating whether data binding can automatically edit items in this collection. More...
 
bool AllowNew [getprotected set]
 Gets or sets a value indicating whether data binding can automatically add new items to this collection. More...
 
bool AllowRemove [getprotected set]
 Gets or sets a value indicating whether data binding can automatically remove items from this collection. More...
 
bool RaiseListChangedEvents [getset]
 Gets or sets a value indicating whether the collection should raise changed events. More...
 
EventHandler< RemovingItemEventArgsRemovingItem
 Implements a serialization-safe RemovingItem event. More...
 
BusyChangedEventHandler BusyChanged
 Event indicating that the busy status of the object has changed. More...
 
virtual bool IsBusy [get]
 Gets the busy status for this object and its child objects. More...
 
virtual bool IsSelfBusy [get]
 Gets the busy status for this object. More...
 
EventHandler< ErrorEventArgsUnhandledAsyncException
 Event indicating that an exception occurred during an async operation. More...
 
EventHandler< Csla.Core.ChildChangedEventArgsChildChanged
 Event raised when a child object has been changed. More...
 
EventHandler< AddedNewEventArgs< T > > AddedNew
 Event raised when a new object has been added to the collection. More...
 
IDisposable SuppressListChangedEvents [get]
 Use this object to suppress ListChangedEvents for an entire code block. More...
 
- Properties inherited from Csla.Core.MobileObservableCollection< T >
LoadListModeObject LoadListMode [get]
 By wrapping this property inside Using block you can set property values on current business object without raising PropertyChanged events and checking user rights. More...
 
- Properties inherited from Csla.Core.INotifyBusy
bool IsBusy [get]
 Gets a value indicating whether the object, or any of the object's child objects, are busy running an asynchronous operation. More...
 
bool IsSelfBusy [get]
 Gets a value indicating whether the object is busy running an asynchronous operation. More...
 
- Properties inherited from Csla.Core.IParent
IParent Parent [get]
 Provide access to the parent reference for use in child object code. More...
 
- Properties inherited from Csla.Core.IBusinessObject
int Identity [get]
 Gets a value representing this object instance's unique identity value within the business object graph. More...
 
- Properties inherited from Csla.Core.IUseApplicationContext
ApplicationContext ApplicationContext [getset]
 Gets or sets the current ApplicationContext object. More...
 

Events

EventHandler< Csla.Core.SavedEventArgsSaved
 Event raised when an object in the list has been saved. More...
 
- Events inherited from Csla.Core.IObservableBindingList
EventHandler< RemovingItemEventArgsRemovingItem
 Event indicating that an item is being removed from the list. More...
 
- Events inherited from Csla.Core.INotifyBusy
BusyChangedEventHandler BusyChanged
 Event raised when the object's busy status changes. More...
 
- Events inherited from Csla.Core.INotifyUnhandledAsyncException
EventHandler< ErrorEventArgsUnhandledAsyncException
 Event indicating that an exception occurred during an asynchronous operation. More...
 
- Events inherited from Csla.Core.INotifyChildChanged
EventHandler< ChildChangedEventArgsChildChanged
 Event indictating that a child object has changed. More...
 

Detailed Description

This is the base class from which collections of editable root business objects should be derived.

Template Parameters
TType of editable root object to contain within the collection.

Your subclass should implement a factory method and should override or overload DataPortal_Fetch() to implement data retrieval.

Saving (inserts or updates) of items in the collection should be handled through the SaveItem() method on the collection.

Removing an item from the collection through Remove() or RemoveAt() causes immediate deletion of the object, by calling the object's Delete() and Save() methods.

Type Constraints
T :Core.IEditableBusinessObject 
T :Core.IUndoableObject 
T :Core.ISavable 
T :IMobileObject 
T :IBusinessObject 

Definition at line 45 of file DynamicListBase.cs.

Constructor & Destructor Documentation

◆ DynamicListBase()

Creates an instance of the type.

Definition at line 57 of file DynamicListBase.cs.

Member Function Documentation

◆ AddNewCore()

override T Csla.DynamicListBase< T >.AddNewCore ( )
protectedvirtual

Adds a new item to the list.

Returns
The added object

Reimplemented from Csla.Core.ObservableBindingList< T >.

Definition at line 307 of file DynamicListBase.cs.

◆ DataPortal_OnDataPortalException()

virtual void Csla.DynamicListBase< T >.DataPortal_OnDataPortalException ( DataPortalEventArgs  e,
Exception  ex 
)
protectedvirtual

Called by the server-side DataPortal if an exception occurs during data access.

Parameters
eThe DataPortalContext object passed to the DataPortal.
exThe Exception thrown during data access.

Definition at line 515 of file DynamicListBase.cs.

◆ DataPortal_OnDataPortalInvoke()

virtual void Csla.DynamicListBase< T >.DataPortal_OnDataPortalInvoke ( DataPortalEventArgs  e)
protectedvirtual

Called by the server-side DataPortal prior to calling the requested DataPortal_xyz method.

Parameters
eThe DataPortalContext object passed to the DataPortal.

Definition at line 492 of file DynamicListBase.cs.

◆ DataPortal_OnDataPortalInvokeComplete()

virtual void Csla.DynamicListBase< T >.DataPortal_OnDataPortalInvokeComplete ( DataPortalEventArgs  e)
protectedvirtual

Called by the server-side DataPortal after calling the requested DataPortal_xyz method.

Parameters
eThe DataPortalContext object passed to the DataPortal.

Definition at line 503 of file DynamicListBase.cs.

◆ Initialize()

virtual void Csla.DynamicListBase< T >.Initialize ( )
protectedvirtual

Override this method to set up event handlers so user code in a partial class can respond to events raised by generated code.

Definition at line 77 of file DynamicListBase.cs.

◆ InsertItem()

override void Csla.DynamicListBase< T >.InsertItem ( int  index,
item 
)
protected

Gives the new object a parent reference to this list.

Parameters
indexIndex at which to insert the item.
itemItem to insert.

Definition at line 321 of file DynamicListBase.cs.

◆ OnCollectionChanged()

override void Csla.DynamicListBase< T >.OnCollectionChanged ( NotifyCollectionChangedEventArgs  e)
protected

Raises the CollectionChanged event.

Parameters
eEvent args object

Definition at line 393 of file DynamicListBase.cs.

◆ OnDeserialized()

override void Csla.DynamicListBase< T >.OnDeserialized ( )
protectedvirtual

Set parent reference.

Reimplemented from Csla.Core.ObservableBindingList< T >.

Definition at line 462 of file DynamicListBase.cs.

◆ OnGetState()

override void Csla.DynamicListBase< T >.OnGetState ( SerializationInfo  info)
protectedvirtual

Override this method to insert your field values into the MobileFormatter serialzation stream.

Parameters
infoObject containing the data to serialize.

Reimplemented from Csla.Core.ObservableBindingList< T >.

Definition at line 586 of file DynamicListBase.cs.

◆ OnSaved()

virtual void Csla.DynamicListBase< T >.OnSaved ( newObject,
Exception  error 
)
protectedvirtual

Raises the Saved event.

Parameters
newObjectObject returned as a result of the save operation.
errorException returned as a result of the save operation.

Definition at line 132 of file DynamicListBase.cs.

◆ OnSetState()

override void Csla.DynamicListBase< T >.OnSetState ( SerializationInfo  info)
protectedvirtual

Override this method to retrieve your field values from the MobileFormatter serialzation stream.

Parameters
infoObject containing the data to serialize.

Reimplemented from Csla.Core.ObservableBindingList< T >.

Definition at line 599 of file DynamicListBase.cs.

◆ RemoveItem()

override async void Csla.DynamicListBase< T >.RemoveItem ( int  index)
protected

Removes an item from the list.

Parameters
indexIndex of the item to be removed.

Definition at line 332 of file DynamicListBase.cs.

◆ SaveItem() [1/2]

async void Csla.DynamicListBase< T >.SaveItem ( int  index)

Saves the specified item in the list.

Parameters
indexIndex of the item to be saved.

This method properly saves the child item, by making sure the item in the collection is properly replaced by the result of the Save() method call.

Definition at line 267 of file DynamicListBase.cs.

◆ SaveItem() [2/2]

void Csla.DynamicListBase< T >.SaveItem ( item)

Saves the specified item in the list.

Parameters
itemReference to the item to be saved.

This method properly saves the child item, by making sure the item in the collection is properly replaced by the result of the Save() method call.

Definition at line 250 of file DynamicListBase.cs.

◆ SaveItemAsync() [1/3]

async Task Csla.DynamicListBase< T >.SaveItemAsync ( int  index)

Saves the specified item in the list.

Parameters
indexIndex of item to be saved.

Definition at line 151 of file DynamicListBase.cs.

◆ SaveItemAsync() [2/3]

virtual async Task Csla.DynamicListBase< T >.SaveItemAsync ( int  index,
bool  delete 
)
protectedvirtual

Saves the specified item in the list.

Parameters
indexIndex of item to be saved.
deletetrue if the item should be deleted.

Definition at line 161 of file DynamicListBase.cs.

◆ SaveItemAsync() [3/3]

async Task Csla.DynamicListBase< T >.SaveItemAsync ( item)

Saves the specified item in the list.

Parameters
itemItem to be saved.

Definition at line 142 of file DynamicListBase.cs.

◆ SetItem()

override void Csla.DynamicListBase< T >.SetItem ( int  index,
item 
)
protected

Replaces item in the list.

Parameters
indexIndex of the item that was replaced.
itemNew item.

Definition at line 366 of file DynamicListBase.cs.

◆ ToArray()

T[] Csla.DynamicListBase< T >.ToArray ( )

Get an array containing all items in the list.

Definition at line 527 of file DynamicListBase.cs.

Property Documentation

◆ ApplicationContext

Gets the current ApplicationContext

Definition at line 67 of file DynamicListBase.cs.

◆ IsBusy

override bool Csla.DynamicListBase< T >.IsBusy
get

Gets a value indicating whether this object or any child object is currently executing an async operation.

Definition at line 440 of file DynamicListBase.cs.

◆ RaiseReplaceEvents

bool Csla.DynamicListBase< T >.RaiseReplaceEvents
getsetprotected

Gets or sets a value indicating whether the Replace event should be raised when OnCollectionChanged() is called.

There's a bug in DataGridDataConnection that throws an exception on the replace action. By default we disable raising the replace event to avoid that bug, but some other datagrid controls require the event.

Definition at line 387 of file DynamicListBase.cs.

◆ SupportsChangeNotificationCore

override bool Csla.DynamicListBase< T >.SupportsChangeNotificationCore
getprotected

Gets a value indicating whether this collection supports change notification (always returns true).

Definition at line 405 of file DynamicListBase.cs.

Event Documentation

◆ Saved

Event raised when an object in the list has been saved.

Definition at line 122 of file DynamicListBase.cs.