CSLA .NET 10.0.0
A home for your business logic
Loading...
Searching...
No Matches
Csla.Blazor.ViewModel< T > Class Template Reference

Base type for creating your own view model. More...

Public Member Functions

 ViewModel (ApplicationContext applicationContext)
 Creates an instance of the type.
async Task< T?> RefreshAsync (Func< Task< T?> > factory)
 Refresh the Model.
async Task SaveAsync ()
 Saves the Model asynchronously.
async Task SaveAsync (CancellationToken ct)
 Saves the Model.
IPropertyInfo GetPropertyInfo< P > (Expression< Func< P > > property)
 Get a PropertyInfo object for a property. PropertyInfo provides access to the meta-state of the property.
IPropertyInfo GetPropertyInfo< P > (string textSeparator, Expression< Func< P > > property)
 Get a PropertyInfo object for a property. PropertyInfo provides access to the meta-state of the property.
IPropertyInfo GetPropertyInfo< P > (Expression< Func< P > > property, string id)
 Get a PropertyInfo object for a property. PropertyInfo provides access to the meta-state of the property.
IPropertyInfo GetPropertyInfo (string propertyName)
 Get a PropertyInfo object for a property of the Model. PropertyInfo provides access to the meta-state of the property.
IPropertyInfo GetPropertyInfo (string propertyName, string id)
 Get a PropertyInfo object for a property of the Model. PropertyInfo provides access to the meta-state of the property.

Protected Member Functions

virtual void OnModelChanging (T? oldValue, T? newValue)
 Raises the ModelChanging event.
void UnhookChangedEvents (T? model)
 Unhooks changed event handlers from the model.
virtual void OnModelChanged ()
 Raises the ModelChanged event.
virtual void OnModelPropertyChanged (object? sender, PropertyChangedEventArgs e)
 Raises the ModelPropertyChanged event.
virtual void OnModelChildChanged (object? sender, ChildChangedEventArgs e)
 Raises the ModelChildChanged event.
virtual void OnModelCollectionChanged (object? sender, NotifyCollectionChangedEventArgs e)
 Raises the ModelCollectionChanged event.
virtual async Task< T?> DoSaveAsync (ISavable? cloned)
 Override to provide custom Model save behavior.
virtual void DoCancel ()
 Cancels changes made to the model if ManagedObjectLifetime is true.

Properties

ApplicationContext ApplicationContext [get]
 Gets the current ApplicationContext instance.
TimeSpan BusyTimeout = TimeSpan.FromSeconds(30) [get, set]
 Gets or sets a value specifying the timeout when calling SaveAsync and the Model is currently busy with async rules.
T? Model [get, set]
 Gets or sets the Model object.
bool ManageObjectLifetime = false [get, set]
 Gets or sets a value indicating whether the view model should manage the lifetime of the business object, including using n-level undo.
bool IsBusy = false [get, protected set]
 Gets a value indicating whether this object is executing an asynchronous process.
string ViewModelErrorText = string.Empty [get, protected set]
 Gets any error text generated by refresh or save operations.
virtual string ModelErrorText [get]
 Gets the first validation error message from the Model.
Exception? Exception [get]
 Gets the last exception caught by the view model during refresh or save operations.
bool CanCreateObject [get, protected set]
 Gets a value indicating whether the current user is authorized to create an instance of the business domain type.
bool CanGetObject [get, protected set]
 Gets a value indicating whether the current user is authorized to retrieve an instance of the business domain type.
bool CanEditObject [get, protected set]
 Gets a value indicating whether the current user is authorized to edit/save an instance of the business domain type.
bool CanDeleteObject [get, protected set]
 Gets a value indicating whether the current user is authorized to delete an instance of the business domain type.

Events

Action? Saved
 Event raised after Model has been saved.
EventHandler< Core.ErrorEventArgs >? Error
 Event raised when failed to save Model.
Action< T?, T?>? ModelChanging
 Event raised when Model is changing.
Action? ModelChanged
 Event raised when Model has changed.
PropertyChangedEventHandler? ModelPropertyChanged
 Event raised when the Model object raises its PropertyChanged event.
Action< object, ChildChangedEventArgs >? ModelChildChanged
 Event raised when the Model object raises its ModelChildChanged event.
Action< object, NotifyCollectionChangedEventArgs >? ModelCollectionChanged
 Event raised when the Model object raises its ModelCollectionChanged event.

Detailed Description

Base type for creating your own view model.

Member Function Documentation

◆ DoCancel()

virtual void Csla.Blazor.ViewModel< T >.DoCancel ( )
inlineprotectedvirtual

Cancels changes made to the model if ManagedObjectLifetime is true.

◆ DoSaveAsync()

virtual async Task< T?> Csla.Blazor.ViewModel< T >.DoSaveAsync ( ISavable? cloned)
inlineprotectedvirtual

Override to provide custom Model save behavior.

◆ GetPropertyInfo() [1/2]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo ( string propertyName)
inline

Get a PropertyInfo object for a property of the Model. PropertyInfo provides access to the meta-state of the property.

Parameters
propertyNameProperty name
Exceptions
ArgumentExceptionpropertyName is null, string.Empty or only consists of white spaces.
InvalidOperationExceptionModel is null.

◆ GetPropertyInfo() [2/2]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo ( string propertyName,
string id )
inline

Get a PropertyInfo object for a property of the Model. PropertyInfo provides access to the meta-state of the property.

Parameters
propertyNameProperty name
idUnique identifier for property in list or array
Exceptions
ArgumentExceptionpropertyName is null, string.Empty or only consists of white spaces.
InvalidOperationExceptionModel is null.

◆ GetPropertyInfo< P >() [1/3]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo< P > ( Expression< Func< P > > property)
inline

Get a PropertyInfo object for a property. PropertyInfo provides access to the meta-state of the property.

Parameters
propertyProperty expression
Exceptions
ArgumentNullExceptionproperty is null.

◆ GetPropertyInfo< P >() [2/3]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo< P > ( Expression< Func< P > > property,
string id )
inline

Get a PropertyInfo object for a property. PropertyInfo provides access to the meta-state of the property.

Parameters
propertyProperty expression
idUnique identifier for property in list or array
Exceptions
ArgumentNullExceptionproperty is null.

◆ GetPropertyInfo< P >() [3/3]

IPropertyInfo Csla.Blazor.ViewModel< T >.GetPropertyInfo< P > ( string textSeparator,
Expression< Func< P > > property )
inline

Get a PropertyInfo object for a property. PropertyInfo provides access to the meta-state of the property.

Parameters
propertyProperty expression
textSeparatortext seprator for concatenating errors
Exceptions
ArgumentNullExceptiontextSeparator or property is null.

◆ OnModelChanged()

virtual void Csla.Blazor.ViewModel< T >.OnModelChanged ( )
inlineprotectedvirtual

Raises the ModelChanged event.

◆ OnModelChanging()

virtual void Csla.Blazor.ViewModel< T >.OnModelChanging ( T? oldValue,
T? newValue )
inlineprotectedvirtual

Raises the ModelChanging event.

Parameters
oldValueOld Model value
newValueNew Model value

◆ OnModelChildChanged()

virtual void Csla.Blazor.ViewModel< T >.OnModelChildChanged ( object? sender,
ChildChangedEventArgs e )
inlineprotectedvirtual

Raises the ModelChildChanged event.

Parameters
sender
e

◆ OnModelCollectionChanged()

virtual void Csla.Blazor.ViewModel< T >.OnModelCollectionChanged ( object? sender,
NotifyCollectionChangedEventArgs e )
inlineprotectedvirtual

Raises the ModelCollectionChanged event.

Parameters
sender
e

◆ OnModelPropertyChanged()

virtual void Csla.Blazor.ViewModel< T >.OnModelPropertyChanged ( object? sender,
PropertyChangedEventArgs e )
inlineprotectedvirtual

Raises the ModelPropertyChanged event.

Parameters
sender
e

◆ RefreshAsync()

async Task< T?> Csla.Blazor.ViewModel< T >.RefreshAsync ( Func< Task< T?> > factory)
inline

Refresh the Model.

Parameters
factoryAsync data portal or factory method
Exceptions
ArgumentNullExceptionfactory is null.

◆ SaveAsync() [1/2]

async Task Csla.Blazor.ViewModel< T >.SaveAsync ( )
inline

Saves the Model asynchronously.

◆ SaveAsync() [2/2]

async Task Csla.Blazor.ViewModel< T >.SaveAsync ( CancellationToken ct)
inline

Saves the Model.

Parameters
ctThe cancellation token.

◆ UnhookChangedEvents()

void Csla.Blazor.ViewModel< T >.UnhookChangedEvents ( T? model)
inlineprotected

Unhooks changed event handlers from the model.

Parameters
model

◆ ViewModel()

Csla.Blazor.ViewModel< T >.ViewModel ( ApplicationContext applicationContext)
inline

Creates an instance of the type.

Parameters
applicationContext
Exceptions
ArgumentNullExceptionapplicationContext is null.

Property Documentation

◆ ApplicationContext

ApplicationContext Csla.Blazor.ViewModel< T >.ApplicationContext
getprotected

Gets the current ApplicationContext instance.

◆ BusyTimeout

TimeSpan Csla.Blazor.ViewModel< T >.BusyTimeout = TimeSpan.FromSeconds(30)
getset

Gets or sets a value specifying the timeout when calling SaveAsync and the Model is currently busy with async rules.

◆ CanCreateObject

bool Csla.Blazor.ViewModel< T >.CanCreateObject
getprotected set

Gets a value indicating whether the current user is authorized to create an instance of the business domain type.

◆ CanDeleteObject

bool Csla.Blazor.ViewModel< T >.CanDeleteObject
getprotected set

Gets a value indicating whether the current user is authorized to delete an instance of the business domain type.

◆ CanEditObject

bool Csla.Blazor.ViewModel< T >.CanEditObject
getprotected set

Gets a value indicating whether the current user is authorized to edit/save an instance of the business domain type.

◆ CanGetObject

bool Csla.Blazor.ViewModel< T >.CanGetObject
getprotected set

Gets a value indicating whether the current user is authorized to retrieve an instance of the business domain type.

◆ Exception

Exception? Csla.Blazor.ViewModel< T >.Exception
get

Gets the last exception caught by the view model during refresh or save operations.

◆ IsBusy

bool Csla.Blazor.ViewModel< T >.IsBusy = false
getprotected set

Gets a value indicating whether this object is executing an asynchronous process.

◆ ManageObjectLifetime

bool Csla.Blazor.ViewModel< T >.ManageObjectLifetime = false
getset

Gets or sets a value indicating whether the view model should manage the lifetime of the business object, including using n-level undo.

◆ Model

T? Csla.Blazor.ViewModel< T >.Model
getset

Gets or sets the Model object.

◆ ModelErrorText

virtual string Csla.Blazor.ViewModel< T >.ModelErrorText
getprotected

Gets the first validation error message from the Model.

◆ ViewModelErrorText

string Csla.Blazor.ViewModel< T >.ViewModelErrorText = string.Empty
getprotected set

Gets any error text generated by refresh or save operations.

Event Documentation

◆ Error

EventHandler<Core.ErrorEventArgs>? Csla.Blazor.ViewModel< T >.Error

Event raised when failed to save Model.

◆ ModelChanged

Action? Csla.Blazor.ViewModel< T >.ModelChanged

Event raised when Model has changed.

◆ ModelChanging

Action<T?, T?>? Csla.Blazor.ViewModel< T >.ModelChanging

Event raised when Model is changing.

◆ ModelChildChanged

Action<object, ChildChangedEventArgs>? Csla.Blazor.ViewModel< T >.ModelChildChanged

Event raised when the Model object raises its ModelChildChanged event.

◆ ModelCollectionChanged

Action<object, NotifyCollectionChangedEventArgs>? Csla.Blazor.ViewModel< T >.ModelCollectionChanged

Event raised when the Model object raises its ModelCollectionChanged event.

◆ ModelPropertyChanged

PropertyChangedEventHandler? Csla.Blazor.ViewModel< T >.ModelPropertyChanged

Event raised when the Model object raises its PropertyChanged event.

◆ Saved

Action? Csla.Blazor.ViewModel< T >.Saved

Event raised after Model has been saved.


The documentation for this class was generated from the following file: