Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Basically, these are my interfaces:
- Type
- ITemplate = interface
- ['{9F4D0F54-E82B-437B-8951-4C5208F4C5F7}']
- // Stuff
- end;
- IRecipients = interface
- ['{47B74B46-AADB-42D2-8740-279309B20573}']
- // Stuff
- end;
- IList = interface
- ['{3D6912E0-5637-4945-BF95-8A9C81CB284E}']
- // Stuff
- end;
- ISegment = interface
- ['{A72A8D70-EC69-4F57-9B70-F65E5D4925FF}']
- // Stuff
- end;
- ICampaign = interface
- ['{464B466A-B4D1-4440-BE43-960BE31FFCB9}']
- // Stuff
- end;
- // This interface exposes all the others
- IBulkEmailSvc = interface
- ['{2E46B50C-EFC0-4E54-B630-2EB30EF1F0C9}']
- function GetTemplate( ID: String ): ITemplate;
- function GetRecipients( ID: String ): IRecipients;
- function GetList( ID: String ): IList;
- function GetSegment( ID: String ): ISegment;
- function GetCampaign( ID: String ): ICampaign;
- end;
- // These are my base classes:
- Type
- TbeServiceBase<T: TCloudBase> = class( TInterfacedObject )
- end;
- TbeRecipients<T: TCloudBase> = class( TbeServiceBase<T>, IRecipients )
- end;
- TbeLists<T:TCloudBase> = class( TbeServiceBase<T>,IList )
- end;
- TbeTemplates< T: TCloudBase> = class( TbeServiceBase<T>,ITemplate )
- end;
- TbeSegments< T: TCloudBase> = class( TbeServiceBase<T>, ISegment )
- end;
- TbeCampaigns< T: TCloudBase > = class( TbeServiceBase<T>, ICampaign )
- end;
- // What I would like here is to be able to have class references for all the above
- // classes so that I can avoid having the functions as abstract and instead have them
- // dynamic with a default implementation which takes from the referenced class types.
- // Makes sense?
- TbeBulkEmailService< T: TCloudBase> = class( TInterfacedObject,IBulkEmailSvc )
- strict protected
- // This is what I'd like to do do:
- function GetCampaignClassType : ClassRefOfTCampaigns<T>;virtual;abstract;
- // And so on for all the others, so that I can - instead - remove "virtual abstract" from the below and have
- // them either static or using "dynamic". In other words, I want to write code such as this in the below:
- // Result := GetCampaignClassType<T>.Create( ID );
- // and specify concrete descendent classes so that it becomes:
- // Type TMyBulkEmailService = class( TMyConnectedComponent ) and because all of them will use the same
- // one, I could write Result := TMyCampaignImplementation in GetCampaignClassType.
- function GetCampaign(ID: string): ICampaign;virtual;abstract;
- function GetList(ID: string): IList;virtual;abstract;
- function GetRecipients(ID: string): IRecipients;virtual;abstract;
- function GetSegment(ID: string): ISegment;virtual;abstract;
- function GetTemplate(ID: string): ITemplate;virtual;abstract;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement