Pipeline & Filter ( ), , , - ( ) . , WPF- . .
Pipeline & Filter
. , (generic) -. . :
ConditionAggregator
- , Condition<T>
. Filter<T>
ConditionAggregator
Condition<T>
(condition) . apply () Filter<T>
, check () ICondition<T>
. ConditionAggregator<T>
OnFilterChanged
. , . Filter .
MVVM . (View Model) MVVM - . -, . ConditionAggregator<T>
OnFilterChanged
, apply. .
Employee
. Generic
T
Filter
Employee
. EmployeeList
. .
public EmployeeList(IEmployeesRepository repository, ConditionAggregator<employee> conditionAggregator)
{
this.repository = repository;
this.filters = new ConcreteFilter<employee>(conditionAggregator);
conditionAggregator.OnFilterChanged += this.FilterList;
_ = initAsync();
}
FilterList
OnFilterChanged
, .
private void FilterList()
{
this.Employees = this.filters.Apply(this.employeesFullList);
}
EmployeesViewModel
. EmployeeTypeselected
, ConditionAggregator
. - -, .
public EmployeesViewModel(IEmployeesRepository repository)
{
this.repository = repository;
Condition<employee> filterEmployee = new Condition<employee>((e) => e.employeeCode == this.EmployeeTypeSelected);
this.conditionAggregator = new ConditionAggregator<employee>(new List<condition<employee>> { filterEmployee });
this.EmployeeList = new EmployeeList(repository, this.conditionAggregator);
}
</condition<employee></employee></employee></employee>
-. , ConditionAggregator
. , , .
WPF.Demo.DataFilter
- WPF. . WPF.Demo.DataFilter.ViewModels
, . WPF.Demo.DataFilter.Common
Pipeline & Filter. WPF.Demo.DataFilter.DAL
json- .
:
" ". "", -, , , . .