Created
December 11, 2009 15:27
-
-
Save mxriverlynn/254270 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppController: IApplicationController | |
{ | |
//other app controller stuff here | |
public R Query<T,R>(T queryData) | |
{ | |
R returnValue = default(R); | |
IQuery<T,R> query = iocContainer.GetInstance<IQuery<T,R>>(); | |
if (query != null) | |
returnValue = query.Query(T); | |
return returnValue; | |
} | |
//other app controller stuff here | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DisplayUsersPresenter.cs | |
{ | |
private IApplicationController AppController{ get; set; } | |
private IDisplayUsersView View{ get; set; } | |
public SomeService(IDisplayUsersView view, IApplicationController appController) | |
{ | |
View = view; | |
AppController = appController; | |
} | |
public void GetAllUsers() | |
{ | |
IList<User> users = AppController.Query<GetAllUsers, IList<User>>(); | |
View.ShowUsers(users); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GetAllUsers | |
{ | |
//empty class used as a marker to determine what query object should be executed | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IQuery<T,R> | |
{ | |
R Query(T queryData); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyRepository: IQuery<GetAllUsers, IList<User>> | |
{ | |
public IList<User> Query(GetAllUsers queryData) | |
{ | |
IList<User> users = //retrieve all users from the database, here.; | |
return users; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment