Skip to end of metadata
Go to start of metadata

Represents the base functionally for view model that perform data retrieval and shows the result in a data list.

Definition

public abstract class DataListViewModelBase<TModel, TRepository> : EditableListViewModelBase<TModel>,

ISupportIncrementalLoading, ISupportRefresh, ISupportCancellation

where TModel : class, new()

where TRepository : IEditableEntityRepository<TModel>, class

Type Parameters

TModel The type of the model.
TRepository The type of the repository.

Summary

The following table summarizes the members exposed in this class.

Public Constructors

Public Properties

AutoLoadData Gets or sets a value indicating whether automatic load data is enabled.
AutoSyncData Gets or sets a value indicating whether automatic synchronize data is enabled.
DeleteText Gets the delete text.
EnableDataSynchronization Gets or sets a value indicating whether the editor should perform data synchronization after save process.
EnableIncrementalLoading Gets or sets a value indicating whether incremental loading is enabled.
EnableIncrementalRefresh Gets or sets a value indicating whether incremental refresh is enabled.
EnableRefresh Gets or sets a value indicating whether refresh is enabled.
ExitEditModeOnDelete Gets or sets a value indicating whether the edit mode should be ended when delete command succeed.
IncrementalLoadingSize Gets or sets the size of the incremental loading.
IsDataFiltering Gets or sets a value indicating whether the data is filtering.
IsDataLoaded Gets or sets a value indicating whether the data is successfuly loaded.
IsDataLoading Gets or sets a value indicating whether the data is loading.
IsDataSaving Gets or sets a value indicating whether the data is saving.
IsDataSyncing Gets or sets a value indicating whether the data is syncing.
IsLocalDataStorageEnabled Gets a value indicating whether local data storage is enabled.
LoadingText Gets or sets the loading text.
ParentEntities Gets the parent entities that own this list.
Repository Gets the data repository.
RequiresInternetConnection Gets a value indicating whether the application requires internet connection.
ServiceDescriptor Gets or sets the service descriptor used for loading data.
TitleText Gets the title text.
TotalItemsText Gets the total items text.

Protected Properties

BindingNavigationProperties Gets collection of binding navigation properties used in the related view.
FilterQuery Gets the filter query.
ViewQuery Gets the view query.

Public Methods

Cancel() Cancel the currently running asynchronous operation.
Filter(string, string) Filters the specified query.
Navigated(NavigatedParameter) Called when this instance is navigated.

Protected Methods

CanExecuteDelete(object) Determines whether the delete command can be executed.
CanExecuteEdit(object) Determines whether the edit command can be executed.
Dispose(bool) Dispose this instance.
ExecuteDelete(object) Executes the delete command.
ExecuteRefresh(object) Executes the refresh.
FinalizeQueryDescriptor(QueryDescriptor) Finalizes the query descriptor prior to data loading process.
GetUpdatedNavigationEntities(ISynchronizationResult, IList<TModel>) Gets the updated navigation entities.
Initialize() Initialize view model.
InitializeSelectParameter(QueryDescriptor) Initializes the select parameter used when loading data.
LoadData() Performs data loading process.
LoadDataCore(QueryDescriptor, DataLoadingMode) Performs data loading process.
LoadDataIncremental() Performs loads incremental data.
LoadPrerequisiteData() Loads the prerequisite data.
NotifyDataChanged(TModel) Notifies the data changed for the specified item.
OnCollectionChanged(NotifyCollectionChangedEventArgs) Called when the collection of items changed.
OnDataLoaded(ISelectResult<TModel>, DataLoadingMode) Called when data is loaded.
OnDataLoading(QueryDescriptor, DataLoadingMode) Called when loading data.
OnDataOperationCompleted(object, DataAction) Called when data operation is completed.
OnDataOperationFailed(Exception, DataAction) Called when data operation failed and throws exception.
OnDataOperationStarting(DataAction) Called when data operation is starting.
OnDataSynchronized(ISynchronizationResult) Called when SynchronizedEvent is triggered.
OnDataSynchronizing(ISynchronizationContext) Called when SynchronizingEvent is triggered.
OnSelectedItemChanged(TModel) Called when the selected item changed.
OnSelectedItemsCollectionChanged(NotifyCollectionChangedEventArgs) Called when the collection of selected items changed.
OnSourceItemsChanged(ICollection<TModel>) Called when the source items changed.
OnSyncParentEntitiesRemoved(IList) Called when the parent entities that own this list have been removed due to data synchronization.
RefreshData() Performs refresh data.
RefreshDataIncremental() Performs refresh data incremental.
SaveDataAsync(DataAction) Saves the data asynchronously.
ValidateNewSynchronizedItem(TModel) Validates the new synchronized item.

Public Constructors

public DataListViewModelBase(IViewModel owner)

Initializes a new instance of the DataListViewModelBase<TModel, TRepository> class.

Parameters

owner

public DataListViewModelBase()

Initializes a new instance of the DataListViewModelBase<TModel, TRepository> class.

Public Properties

public bool AutoLoadData { get; set; }

Gets or sets a value indicating whether automatic load data is enabled.

public bool AutoSyncData { get; set; }

Gets or sets a value indicating whether automatic synchronize data is enabled.

public string DeleteText { get; }

Gets the delete text.

public bool EnableDataSynchronization { get; set; }

Gets or sets a value indicating whether the editor should perform data synchronization after save process.

public bool EnableIncrementalLoading { get; set; }

Gets or sets a value indicating whether incremental loading is enabled.

public bool EnableIncrementalRefresh { get; set; }

Gets or sets a value indicating whether incremental refresh is enabled.

public bool EnableRefresh { get; set; }

Gets or sets a value indicating whether refresh is enabled.

public bool ExitEditModeOnDelete { get; set; }

Gets or sets a value indicating whether the edit mode should be ended when delete command succeed.

public int IncrementalLoadingSize { get; set; }

Gets or sets the size of the incremental loading.

public bool IsDataFiltering { get; set; }

Gets or sets a value indicating whether the data is filtering.

public bool IsDataLoaded { get; set; }

Gets or sets a value indicating whether the data is successfuly loaded.

public bool IsDataLoading { get; set; }

Gets or sets a value indicating whether the data is loading.

public bool IsDataSaving { get; set; }

Gets or sets a value indicating whether the data is saving.

public bool IsDataSyncing { get; set; }

Gets or sets a value indicating whether the data is syncing.

public bool IsLocalDataStorageEnabled { get; }

Gets a value indicating whether local data storage is enabled.

public string LoadingText { get; set; }

Gets or sets the loading text.

public IList ParentEntities { get; }

Gets the parent entities that own this list.

public TRepository Repository { get; }

Gets the data repository.

public bool RequiresInternetConnection { get; }

Gets a value indicating whether the application requires internet connection.

public ServiceDescriptor ServiceDescriptor { get; set; }

Gets or sets the service descriptor used for loading data.

public string TitleText { get; }

Gets the title text.

public string TotalItemsText { get; }

Gets the total items text.

Protected Properties

protected List<string> BindingNavigationProperties { get; set; }

Gets collection of binding navigation properties used in the related view.

protected IQueryDefinition FilterQuery { get; }

Gets the filter query.

protected IQueryDefinition ViewQuery { get; }

Gets the view query.

Public Methods

public void Cancel()

Cancel the currently running asynchronous operation.

public void Filter(string query, string scope)

Filters the specified query.

Parameters

query The query.
scope The scope.

public void Navigated(NavigatedParameter parameter)

Called when this instance is navigated.

Parameters

parameter Parameter.

Protected Methods

protected bool CanExecuteDelete(object parameter)

Determines whether the delete command can be executed.

Parameters

parameter Parameter.

Return Types

true if the delete command can be executed; otherwise, false.

protected bool CanExecuteEdit(object parameter)

Determines whether the edit command can be executed.

Parameters

parameter Parameter.

Return Types

true if the edit command can be executed; otherwise, false.

protected void Dispose(bool isDisposing)

Dispose this instance.

Parameters

isDisposing If set to true is disposing.

protected void ExecuteDelete(object parameter)

Executes the delete command.

Parameters

parameter Parameter.

protected void ExecuteRefresh(object parameter)

Executes the refresh.

Parameters

parameter The parameter.

protected void FinalizeQueryDescriptor(QueryDescriptor queryDescriptor)

Finalizes the query descriptor prior to data loading process.

Parameters

queryDescriptor Query descriptor.

protected IList<TModel> GetUpdatedNavigationEntities(ISynchronizationResult result, IList<TModel> updatedItems)

Gets the updated navigation entities.

Parameters

result The result.
updatedItems The updated items.

protected void Initialize()

Initialize view model.

protected SelectParameter InitializeSelectParameter(QueryDescriptor queryDescriptor)

Initializes the select parameter used when loading data.

Parameters

queryDescriptor Query descriptor.

Return Types

The select parameter.

protected void LoadData()

Performs data loading process.

protected void LoadDataCore(QueryDescriptor queryDescriptor, DataLoadingMode loadingMode)

Performs data loading process.

Parameters

queryDescriptor The query descriptor.
loadingMode The loading mode.

protected void LoadDataIncremental()

Performs loads incremental data.

Exceptions

InvalidOperationException Load data incrementally requires a valid ViewQuery instance.

protected Task LoadPrerequisiteData()

Loads the prerequisite data.

protected void NotifyDataChanged(TModel item)

Notifies the data changed for the specified item.

Parameters

item The item to be notified.

protected void OnCollectionChanged(NotifyCollectionChangedEventArgs e)

Called when the collection of items changed.

Parameters

e Event argument.

protected void OnDataLoaded(ISelectResult<TModel> selectResult, DataLoadingMode loadingMode)

Called when data is loaded.

Parameters

selectResult The select result.
loadingMode The loading mode.

protected bool OnDataLoading(QueryDescriptor queryDescriptor, DataLoadingMode loadingMode)

Called when loading data.

Parameters

queryDescriptor The query descriptor.
loadingMode The loading mode.

protected void OnDataOperationCompleted(object operationResult, DataAction action)

Called when data operation is completed.

Parameters

operationResult The operation result.
action The action.

protected void OnDataOperationFailed(Exception exception, DataAction action)

Called when data operation failed and throws exception.

Parameters

exception The exception.
action The action.

protected void OnDataOperationStarting(DataAction action)

Called when data operation is starting.

Parameters

action The action.

protected void OnDataSynchronized(ISynchronizationResult result)

Called when SynchronizedEvent is triggered.

Parameters

result The synchronization result.

protected void OnDataSynchronizing(ISynchronizationContext context)

Called when SynchronizingEvent is triggered.

Parameters

context The synchronization context.

protected void OnSelectedItemChanged(TModel newItem)

Called when the selected item changed.

Parameters

newItem The new item.

protected void OnSelectedItemsCollectionChanged(NotifyCollectionChangedEventArgs e)

Called when the collection of selected items changed.

Parameters

e Event argument.

protected void OnSourceItemsChanged(ICollection<TModel> items)

Called when the source items changed.

Parameters

items Event argument.

protected void OnSyncParentEntitiesRemoved(IList parentEntities)

Called when the parent entities that own this list have been removed due to data synchronization.

Parameters

parentEntities Parent entities.

protected void RefreshData()

Performs refresh data.

protected void RefreshDataIncremental()

Performs refresh data incremental.

Exceptions

InvalidOperationException Refresh data incrementally requires a valid ViewQuery instance.

protected Task<bool> SaveDataAsync(DataAction triggerAction)

Saves the data asynchronously.

Parameters

triggerAction The trigger action.

protected bool ValidateNewSynchronizedItem(TModel item)

Validates the new synchronized item.

Parameters

item Item.

Return Types

true, if new synchronized item was validated, false otherwise.
  • No labels