Advertisement
Guest User

Untitled

a guest
Jul 19th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. // Basically, these are my interfaces:
  2. Type
  3. ITemplate = interface
  4. ['{9F4D0F54-E82B-437B-8951-4C5208F4C5F7}']
  5. // Stuff
  6. end;
  7.  
  8. IRecipients = interface
  9. ['{47B74B46-AADB-42D2-8740-279309B20573}']
  10. // Stuff
  11. end;
  12.  
  13. IList = interface
  14. ['{3D6912E0-5637-4945-BF95-8A9C81CB284E}']
  15. // Stuff
  16. end;
  17.  
  18. ISegment = interface
  19. ['{A72A8D70-EC69-4F57-9B70-F65E5D4925FF}']
  20. // Stuff
  21. end;
  22.  
  23. ICampaign = interface
  24. ['{464B466A-B4D1-4440-BE43-960BE31FFCB9}']
  25. // Stuff
  26. end;
  27.  
  28. // This interface exposes all the others
  29. IBulkEmailSvc = interface
  30. ['{2E46B50C-EFC0-4E54-B630-2EB30EF1F0C9}']
  31. function GetTemplate( ID: String ): ITemplate;
  32. function GetRecipients( ID: String ): IRecipients;
  33. function GetList( ID: String ): IList;
  34. function GetSegment( ID: String ): ISegment;
  35. function GetCampaign( ID: String ): ICampaign;
  36. end;
  37.  
  38. // These are my base classes:
  39. Type
  40. TbeServiceBase<T: TCloudBase> = class( TInterfacedObject )
  41. end;
  42.  
  43. TbeRecipients<T: TCloudBase> = class( TbeServiceBase<T>, IRecipients )
  44. end;
  45.  
  46. TbeLists<T:TCloudBase> = class( TbeServiceBase<T>,IList )
  47. end;
  48.  
  49. TbeTemplates< T: TCloudBase> = class( TbeServiceBase<T>,ITemplate )
  50. end;
  51.  
  52. TbeSegments< T: TCloudBase> = class( TbeServiceBase<T>, ISegment )
  53. end;
  54.  
  55. TbeCampaigns< T: TCloudBase > = class( TbeServiceBase<T>, ICampaign )
  56. end;
  57.  
  58. // What I would like here is to be able to have class references for all the above
  59. // classes so that I can avoid having the functions as abstract and instead have them
  60. // dynamic with a default implementation which takes from the referenced class types.
  61. // Makes sense?
  62. TbeBulkEmailService< T: TCloudBase> = class( TInterfacedObject,IBulkEmailSvc )
  63. strict protected
  64. // This is what I'd like to do do:
  65. function GetCampaignClassType : ClassRefOfTCampaigns<T>;virtual;abstract;
  66. // And so on for all the others, so that I can - instead - remove "virtual abstract" from the below and have
  67. // them either static or using "dynamic". In other words, I want to write code such as this in the below:
  68. // Result := GetCampaignClassType<T>.Create( ID );
  69. // and specify concrete descendent classes so that it becomes:
  70. // Type TMyBulkEmailService = class( TMyConnectedComponent ) and because all of them will use the same
  71. // one, I could write Result := TMyCampaignImplementation in GetCampaignClassType.
  72. function GetCampaign(ID: string): ICampaign;virtual;abstract;
  73. function GetList(ID: string): IList;virtual;abstract;
  74. function GetRecipients(ID: string): IRecipients;virtual;abstract;
  75. function GetSegment(ID: string): ISegment;virtual;abstract;
  76. function GetTemplate(ID: string): ITemplate;virtual;abstract;
  77. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement