C# Class Catel.MVVM.Providers.LogicBase

Base implementation of the behaviors, which defines all the different possible situations a behavior must implement / support to be a valid MVVM provider behavior.
Inheritance: ObservableObject, IViewLoadState, IUniqueIdentifyable
Mostra file Open project: Catel/Catel Class Usage Examples

Protected Properties

Property Type Description
ViewLoadManager IViewLoadManager
_lockObject object

Private Properties

Property Type Description
ConstructViewModelUsingArgumentOrDefaultConstructor IViewModel
DetermineInterestingViewProperties List
InitializeViewModelAsync Task
LogicBase System
OnTargetViewLoadedInternal void
OnTargetViewLoadingInternal void
OnTargetViewPropertyChangedInternal void
OnTargetViewUnloadedInternal void
OnTargetViewUnloadingInternal void

Public Methods

Method Description
CancelAndCloseViewModelAsync ( ) : Task

Cancels and closes the view model.

CancelViewModelAsync ( ) : Task

Cancels the view model.

CloseViewModelAsync ( bool result ) : Task

Closes the view model.

OnTargetViewDataContextChanged ( object sender, DataContextChangedEventArgs e ) : void

Called when the DataContext property of the TargetView has changed.

OnTargetViewLoadedAsync ( object sender, EventArgs e ) : Task

Called when the TargetView has just been loaded. The base implementation will try to create a view model based on the current DataContext and set it as the DataContext of the TargetView. To create custom logic for view model creation, override this method and do not call the base.

OnTargetViewPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Called when a property on the TargetView has changed.

OnTargetViewUnloadedAsync ( object sender, EventArgs e ) : Task

Called when the TargetView has just been unloaded.

OnViewLoadedManagerLoadedInternal ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is loaded. This method is public because the view loaded manager must be subscribed to as a weak event.

OnViewLoadedManagerLoadingInternal ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is unloading. This method is public because the view loaded manager must be subscribed to as a weak event.

OnViewLoadedManagerUnloadedInternal ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is unloaded. This method is public because the view loaded manager must be subscribed to as a weak event.

OnViewLoadedManagerUnloadingInternal ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is unloading. This method is public because the view loaded manager must be subscribed to as a weak event.

OnViewModelCanceledAsync ( object sender, EventArgs e ) : Task

Called when the ViewModel has been saved.

OnViewModelClosedAsync ( object sender, ViewModelClosedEventArgs e ) : Task

Called when the ViewModel has been closed.

OnViewModelPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void

Called when a property on the ViewModel has changed.

OnViewModelSavedAsync ( object sender, EventArgs e ) : Task

Called when the ViewModel has been saved.

SaveAndCloseViewModelAsync ( ) : Task

Saves and closes the view model. If the saving fails, the view model is not closed.

SaveViewModelAsync ( ) : Task

Saves the view model.

ValidateViewModel ( ) : bool

Validates the view model.

Protected Methods

Method Description
CompleteViewModelClosingAsync ( ) : Task

Awaits until the closing of the view model is completed.

ConstructViewModelUsingArgumentOrDefaultConstructor ( object injectionObject ) : IViewModel

Tries to construct the view model using the argument. If that fails, it will try to use the default constructor of the view model. If that is not available, null is returned.

CreateViewModelByUsingDataContextOrConstructor ( ) : IViewModel

Creates a view model by using data context or, if that is not possible, the constructor of the view model.

IsCurrentDataContext ( DataContextChangedEventArgs e ) : bool

Gets a value indicating whether the specified arguments represent the current data context.

LogicBase ( IView targetView, Type viewModelType = null, IViewModel viewModel = null ) : System

Initializes a new instance of the LogicBase class.

OnViewLoadedManagerLoaded ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is loaded.

OnViewLoadedManagerLoading ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is unloading.

OnViewLoadedManagerUnloaded ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is unloaded.

OnViewLoadedManagerUnloading ( object sender, ViewLoadEventArgs e ) : void

Called when the view manager is unloading.

OnViewModelChanged ( ) : void

Called when the ViewModel property has just been changed.

OnViewModelChanging ( ) : void

Called when the ViewModel property is about to change.

SetDataContext ( object newDataContext ) : void

Sets the data context of the target control. This method is abstract because the real logic implementation knows how to set the data context (for example, by using an additional data context grid).

Private Methods

Method Description
ConstructViewModelUsingArgumentOrDefaultConstructor ( object injectionObject, Type viewModelType ) : IViewModel

Tries to construct the view model using the argument. If that fails, it will try to use the default constructor of the view model. If that is not available, null is returned.

DetermineInterestingViewProperties ( ) : List

Determines the interesting view properties.

InitializeViewModelAsync ( ) : Task
LogicBase ( ) : System

Initializes static members of the LogicBase class.

OnTargetViewLoadedInternal ( object sender, EventArgs e ) : void

Called when the TargetView has just been loaded.

This method will call the OnTargetViewLoadedAsync which can be overriden for custom behavior. This method is required to protect from duplicate loaded events.

OnTargetViewLoadingInternal ( object sender, EventArgs e ) : void

Called when the TargetView is about to be loaded.

OnTargetViewPropertyChangedInternal ( object sender, PropertyChangedEventArgs e ) : void

Called when a property on the TargetView has changed.

OnTargetViewUnloadedInternal ( object sender, EventArgs e ) : void

Called when the TargetView has just been unloaded.

This method will call the OnTargetViewUnloadedAsync which can be overriden for custom behavior. This method is required to protect from duplicate unloaded events.

OnTargetViewUnloadingInternal ( object sender, EventArgs e ) : void

Called when the TargetView is about to be unloaded.

Method Details

CancelAndCloseViewModelAsync() public method

Cancels and closes the view model.
public CancelAndCloseViewModelAsync ( ) : Task
return Task

CancelViewModelAsync() public method

Cancels the view model.
public CancelViewModelAsync ( ) : Task
return Task

CloseViewModelAsync() public method

Closes the view model.
public CloseViewModelAsync ( bool result ) : Task
result bool
return Task

CompleteViewModelClosingAsync() protected method

Awaits until the closing of the view model is completed.
protected CompleteViewModelClosingAsync ( ) : Task
return Task

ConstructViewModelUsingArgumentOrDefaultConstructor() protected method

Tries to construct the view model using the argument. If that fails, it will try to use the default constructor of the view model. If that is not available, null is returned.
protected ConstructViewModelUsingArgumentOrDefaultConstructor ( object injectionObject ) : IViewModel
injectionObject object The object that is injected into the view model constructor.
return IViewModel

CreateViewModelByUsingDataContextOrConstructor() protected method

Creates a view model by using data context or, if that is not possible, the constructor of the view model.
protected CreateViewModelByUsingDataContextOrConstructor ( ) : IViewModel
return IViewModel

IsCurrentDataContext() protected method

Gets a value indicating whether the specified arguments represent the current data context.
protected IsCurrentDataContext ( DataContextChangedEventArgs e ) : bool
e DataContextChangedEventArgs
return bool

LogicBase() protected method

Initializes a new instance of the LogicBase class.
The is null. The is null. The does not implement interface .
protected LogicBase ( IView targetView, Type viewModelType = null, IViewModel viewModel = null ) : System
targetView IView The target control.
viewModelType System.Type Type of the view model.
viewModel IViewModel The view model.
return System

OnTargetViewDataContextChanged() public method

Called when the DataContext property of the TargetView has changed.
public OnTargetViewDataContextChanged ( object sender, DataContextChangedEventArgs e ) : void
sender object The sender.
e DataContextChangedEventArgs The instance containing the event data.
return void

OnTargetViewLoadedAsync() public method

Called when the TargetView has just been loaded. The base implementation will try to create a view model based on the current DataContext and set it as the DataContext of the TargetView. To create custom logic for view model creation, override this method and do not call the base.
public OnTargetViewLoadedAsync ( object sender, EventArgs e ) : Task
sender object The sender.
e System.EventArgs The instance containing the event data.
return Task

OnTargetViewPropertyChanged() public method

Called when a property on the TargetView has changed.
public OnTargetViewPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object The sender.
e System.ComponentModel.PropertyChangedEventArgs The instance containing the event data.
return void

OnTargetViewUnloadedAsync() public method

Called when the TargetView has just been unloaded.
public OnTargetViewUnloadedAsync ( object sender, EventArgs e ) : Task
sender object The sender.
e System.EventArgs The instance containing the event data.
return Task

OnViewLoadedManagerLoaded() protected method

Called when the view manager is loaded.
protected OnViewLoadedManagerLoaded ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerLoadedInternal() public method

Called when the view manager is loaded. This method is public because the view loaded manager must be subscribed to as a weak event.
public OnViewLoadedManagerLoadedInternal ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerLoading() protected method

Called when the view manager is unloading.
protected OnViewLoadedManagerLoading ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerLoadingInternal() public method

Called when the view manager is unloading. This method is public because the view loaded manager must be subscribed to as a weak event.
public OnViewLoadedManagerLoadingInternal ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerUnloaded() protected method

Called when the view manager is unloaded.
protected OnViewLoadedManagerUnloaded ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerUnloadedInternal() public method

Called when the view manager is unloaded. This method is public because the view loaded manager must be subscribed to as a weak event.
public OnViewLoadedManagerUnloadedInternal ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerUnloading() protected method

Called when the view manager is unloading.
protected OnViewLoadedManagerUnloading ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewLoadedManagerUnloadingInternal() public method

Called when the view manager is unloading. This method is public because the view loaded manager must be subscribed to as a weak event.
public OnViewLoadedManagerUnloadingInternal ( object sender, ViewLoadEventArgs e ) : void
sender object The sender.
e ViewLoadEventArgs The instance containing the event data.
return void

OnViewModelCanceledAsync() public method

Called when the ViewModel has been saved.
public OnViewModelCanceledAsync ( object sender, EventArgs e ) : Task
sender object The sender.
e System.EventArgs The instance containing the event data.
return Task

OnViewModelChanged() protected method

Called when the ViewModel property has just been changed.
protected OnViewModelChanged ( ) : void
return void

OnViewModelChanging() protected method

Called when the ViewModel property is about to change.
protected OnViewModelChanging ( ) : void
return void

OnViewModelClosedAsync() public method

Called when the ViewModel has been closed.
public OnViewModelClosedAsync ( object sender, ViewModelClosedEventArgs e ) : Task
sender object The sender.
e ViewModelClosedEventArgs The instance containing the event data.
return Task

OnViewModelPropertyChanged() public method

Called when a property on the ViewModel has changed.
public OnViewModelPropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object The sender.
e System.ComponentModel.PropertyChangedEventArgs The instance containing the event data.
return void

OnViewModelSavedAsync() public method

Called when the ViewModel has been saved.
public OnViewModelSavedAsync ( object sender, EventArgs e ) : Task
sender object The sender.
e System.EventArgs The instance containing the event data.
return Task

SaveAndCloseViewModelAsync() public method

Saves and closes the view model. If the saving fails, the view model is not closed.
public SaveAndCloseViewModelAsync ( ) : Task
return Task

SaveViewModelAsync() public method

Saves the view model.
public SaveViewModelAsync ( ) : Task
return Task

SetDataContext() protected abstract method

Sets the data context of the target control. This method is abstract because the real logic implementation knows how to set the data context (for example, by using an additional data context grid).
protected abstract SetDataContext ( object newDataContext ) : void
newDataContext object The new data context.
return void

ValidateViewModel() public method

Validates the view model.
public ValidateViewModel ( ) : bool
return bool

Property Details

ViewLoadManager protected_oe static_oe property

The view loaded manager.
protected static IViewLoadManager ViewLoadManager
return IViewLoadManager

_lockObject protected_oe property

The lock object.
protected object _lockObject
return object