using System;
using System.Linq;
using DevExpress.Mvvm.DataModel;
using DevExpress.Mvvm.POCO;
using DevExpress.Mvvm.ViewModel;
namespace DevExpress.DevAV.Common.ViewModel {
///
/// The base class for POCO view models exposing a read-only collection of entities of a given type.
/// This is a partial class that provides the extension point to add custom properties, commands and override methods without modifying the auto-generated code.
///
/// An entity type.
/// A unit of work type.
public partial class ReadOnlyCollectionViewModel : ReadOnlyCollectionViewModel
where TEntity : class
where TUnitOfWork : IUnitOfWork {
///
/// Creates a new instance of ReadOnlyCollectionViewModel as a POCO view model.
///
/// A factory used to create a unit of work instance.
/// A function that returns a repository representing entities of the given type.
/// An optional parameter that provides a LINQ function used to customize a query for entities. The parameter, for example, can be used for sorting data.
public static ReadOnlyCollectionViewModel CreateReadOnlyCollectionViewModel(
IUnitOfWorkFactory unitOfWorkFactory,
Func> getRepositoryFunc,
Func, IQueryable> projection = null,
UnitOfWorkPolicy unitOfWorkPolicy = UnitOfWorkPolicy.Individual) {
return ViewModelSource.Create(() => new ReadOnlyCollectionViewModel(unitOfWorkFactory, getRepositoryFunc, projection, unitOfWorkPolicy));
}
///
/// Initializes a new instance of the ReadOnlyCollectionViewModel class.
/// This constructor is declared protected to avoid an undesired instantiation of the PeekCollectionViewModel type without the POCO proxy factory.
///
/// A factory used to create a unit of work instance.
/// A function that returns a repository representing entities of the given type.
/// An optional parameter that provides a LINQ function used to customize a query for entities. The parameter, for example, can be used for sorting data.
protected ReadOnlyCollectionViewModel(
IUnitOfWorkFactory unitOfWorkFactory,
Func> getRepositoryFunc,
Func, IQueryable> projection = null,
UnitOfWorkPolicy unitOfWorkPolicy = UnitOfWorkPolicy.Individual)
: base(unitOfWorkFactory, getRepositoryFunc, projection, unitOfWorkPolicy) {
}
}
///
/// The base class for POCO view models exposing a read-only collection of entities of a given type.
/// This is a partial class that provides the extension point to add custom properties, commands and override methods without modifying the auto-generated code.
///
/// A repository entity type.
/// A projection entity type.
/// A unit of work type.
public partial class ReadOnlyCollectionViewModel : ReadOnlyCollectionViewModelBase
where TEntity : class
where TProjection : class
where TUnitOfWork : IUnitOfWork {
///
/// Creates a new instance of ReadOnlyCollectionViewModel as a POCO view model.
///
/// A factory used to create a unit of work instance.
/// A function that returns the repository representing entities of a given type.
/// A LINQ function used to customize a query for entities. The parameter, for example, can be used for sorting data and/or for projecting data to a custom type that does not match the repository entity type.
public static ReadOnlyCollectionViewModel CreateReadOnlyProjectionCollectionViewModel(
IUnitOfWorkFactory unitOfWorkFactory,
Func> getRepositoryFunc,
Func, IQueryable> projection,
UnitOfWorkPolicy unitOfWorkPolicy = UnitOfWorkPolicy.Individual) {
return ViewModelSource.Create(() => new ReadOnlyCollectionViewModel(unitOfWorkFactory, getRepositoryFunc, projection, unitOfWorkPolicy));
}
///
/// Initializes a new instance of the ReadOnlyCollectionViewModel class.
/// This constructor is declared protected to avoid an undesired instantiation of the PeekCollectionViewModel type without the POCO proxy factory.
///
/// A factory used to create a unit of work instance.
/// A function that returns the repository representing entities of a given type.
/// A LINQ function used to customize a query for entities. The parameter, for example, can be used for sorting data and/or for projecting data to a custom type that does not match the repository entity type.
protected ReadOnlyCollectionViewModel(
IUnitOfWorkFactory unitOfWorkFactory,
Func> getRepositoryFunc,
Func, IQueryable> projection,
UnitOfWorkPolicy unitOfWorkPolicy = UnitOfWorkPolicy.Individual)
: base(unitOfWorkFactory, getRepositoryFunc, projection, unitOfWorkPolicy) {
}
}
}