Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public class AbstractFactory<T> {
  2.  
  3. public delegate List<T> AbstractProductCreator();
  4.  
  5. private Dictionary<string, AbstractProductCreator> _creators = new Dictionary<string, AbstractProductCreator>();
  6.  
  7. private static AbstractFactory<T> _instance = null;
  8. public static AbstractFactory<T> Instance {
  9. get {
  10.  
  11. if( _instance == null ) {
  12.  
  13. _instance = new AbstractFactory<T>();
  14. }
  15.  
  16. return _instance;
  17. }
  18. }
  19.  
  20. private AbstractFactory() { }
  21.  
  22. public bool registerProduct( string setName, AbstractProductCreator creator ) {
  23.  
  24. if( !_creators.ContainsKey( setName ) ) {
  25.  
  26. _creators[setName] = creator;
  27. return true;
  28. }
  29.  
  30. return false;
  31. }
  32.  
  33. public List<T> getProduct( string setName ) {
  34.  
  35. if( _creators.ContainsKey( setName ) ) {
  36.  
  37. return (_creators[setName])();
  38. }
  39.  
  40. return null;
  41. }
  42. }
  43.  
  44. public interface IEntitySetMgr<T> {
  45.  
  46. /// <summary>
  47. /// The columns involved in the query. Only fields in those columns
  48. /// will be retrieved from the db.
  49. /// </summary>
  50. List<ColumnInfo> Columns { get; set; }
  51.  
  52. /// <summary>
  53. /// The number of entities found in the last query to db.
  54. /// </summary>
  55. int EntityCount { get; }
  56.  
  57. bool Init();
  58.  
  59. bool Synch( QueryFilter queryFilter = null );
  60.  
  61. /// <summary>
  62. /// Retrieves the entities build from data of db.
  63. /// </summary>
  64. ObservableCollection<T> GetEntities();
  65. }
  66.  
  67. public class EntitySetMgrFactory : AbstractFactory<IEntitySetMgr<T>> {
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement