Line data Source code
1 : using Cqrs.Configuration;
2 :
3 : namespace Cqrs.Repositories.Queries
4 : {
5 : public class QueryFactory : IQueryFactory
6 0 : {
7 : protected IDependencyResolver DependencyResolver { get; private set; }
8 :
9 0 : public QueryFactory(IDependencyResolver dependencyResolver)
10 : {
11 : DependencyResolver = dependencyResolver;
12 : }
13 :
14 0 : public ISingleResultQuery<TUserQueryStrategy, TData> CreateNewSingleResultQuery<TUserQueryStrategy, TData>()
15 : where TUserQueryStrategy : IQueryStrategy
16 : {
17 : var queryStrategy = DependencyResolver.Resolve<TUserQueryStrategy>();
18 : return new SingleResultQuery<TUserQueryStrategy, TData>
19 : {
20 : QueryStrategy = queryStrategy
21 : };
22 : }
23 :
24 0 : public ICollectionResultQuery<TUserQueryStrategy, TData> CreateNewCollectionResultQuery<TUserQueryStrategy, TData>()
25 : where TUserQueryStrategy : IQueryStrategy
26 : {
27 : var queryStrategy = DependencyResolver.Resolve<TUserQueryStrategy>();
28 : return new CollectionResultQuery<TUserQueryStrategy, TData>
29 : {
30 : QueryStrategy = queryStrategy
31 : };
32 : }
33 : }
34 : }
|