C# Класс 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.
Наследование: ObservableObject, IViewLoadState, IUniqueIdentifyable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
ViewLoadManager IViewLoadManager
_lockObject object

Private Properties

Свойство Тип Описание
ConstructViewModelUsingArgumentOrDefaultConstructor IViewModel
DetermineInterestingViewProperties List
InitializeViewModelAsync Task
LogicBase System
OnTargetViewLoadedInternal void
OnTargetViewLoadingInternal void
OnTargetViewPropertyChangedInternal void
OnTargetViewUnloadedInternal void
OnTargetViewUnloadingInternal void

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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).

Приватные методы

Метод Описание
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.

Описание методов

CancelAndCloseViewModelAsync() публичный Метод

Cancels and closes the view model.
public CancelAndCloseViewModelAsync ( ) : Task
Результат Task

CancelViewModelAsync() публичный Метод

Cancels the view model.
public CancelViewModelAsync ( ) : Task
Результат Task

CloseViewModelAsync() публичный Метод

Closes the view model.
public CloseViewModelAsync ( bool result ) : Task
result bool
Результат Task

CompleteViewModelClosingAsync() защищенный Метод

Awaits until the closing of the view model is completed.
protected CompleteViewModelClosingAsync ( ) : Task
Результат Task

ConstructViewModelUsingArgumentOrDefaultConstructor() защищенный Метод

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.
Результат IViewModel

CreateViewModelByUsingDataContextOrConstructor() защищенный Метод

Creates a view model by using data context or, if that is not possible, the constructor of the view model.
protected CreateViewModelByUsingDataContextOrConstructor ( ) : IViewModel
Результат IViewModel

IsCurrentDataContext() защищенный Метод

Gets a value indicating whether the specified arguments represent the current data context.
protected IsCurrentDataContext ( DataContextChangedEventArgs e ) : bool
e DataContextChangedEventArgs
Результат bool

LogicBase() защищенный Метод

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.
Результат System

OnTargetViewDataContextChanged() публичный Метод

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.
Результат void

OnTargetViewLoadedAsync() публичный Метод

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.
Результат Task

OnTargetViewPropertyChanged() публичный Метод

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.
Результат void

OnTargetViewUnloadedAsync() публичный Метод

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.
Результат Task

OnViewLoadedManagerLoaded() защищенный Метод

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.
Результат void

OnViewLoadedManagerLoadedInternal() публичный Метод

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.
Результат void

OnViewLoadedManagerLoading() защищенный Метод

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.
Результат void

OnViewLoadedManagerLoadingInternal() публичный Метод

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.
Результат void

OnViewLoadedManagerUnloaded() защищенный Метод

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.
Результат void

OnViewLoadedManagerUnloadedInternal() публичный Метод

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.
Результат void

OnViewLoadedManagerUnloading() защищенный Метод

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.
Результат void

OnViewLoadedManagerUnloadingInternal() публичный Метод

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.
Результат void

OnViewModelCanceledAsync() публичный Метод

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.
Результат Task

OnViewModelChanged() защищенный Метод

Called when the ViewModel property has just been changed.
protected OnViewModelChanged ( ) : void
Результат void

OnViewModelChanging() защищенный Метод

Called when the ViewModel property is about to change.
protected OnViewModelChanging ( ) : void
Результат void

OnViewModelClosedAsync() публичный Метод

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.
Результат Task

OnViewModelPropertyChanged() публичный Метод

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.
Результат void

OnViewModelSavedAsync() публичный Метод

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.
Результат Task

SaveAndCloseViewModelAsync() публичный Метод

Saves and closes the view model. If the saving fails, the view model is not closed.
public SaveAndCloseViewModelAsync ( ) : Task
Результат Task

SaveViewModelAsync() публичный Метод

Saves the view model.
public SaveViewModelAsync ( ) : Task
Результат Task

SetDataContext() защищенный абстрактный Метод

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.
Результат void

ValidateViewModel() публичный Метод

Validates the view model.
public ValidateViewModel ( ) : bool
Результат bool

Описание свойств

ViewLoadManager защищенное статическое свойство

The view loaded manager.
protected static IViewLoadManager ViewLoadManager
Результат IViewLoadManager

_lockObject защищенное свойство

The lock object.
protected object _lockObject
Результат object