Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Renderer
- {
- Tenant _tenant;
- void Render(ContentType type)
- {
- switch (type)
- {
- case ContentType.JSON:
- _tenant.RenderJSON();
- break;
- default:
- _tenant.RenderHTML();
- break;
- }
- }
- }
- class Tenant
- {
- virtual void RenderJSON() { ... };
- virtual void RenderHTML() { ... };
- }
- class JoeBlow : Tenant
- {
- override void RenderJSON() { // joe blow's json };
- }
- // uses a DefaultContentTypeDelegate
- IRenderer tenantADefault = new TenantARenderer();
- // specify a specific content type helper object
- IRenderer tenantAType1 = new TenantARender(new ContentType1Delegate());
- class TenantARenderer : IRenderer {
- ...
- public render() {
- // do a bunch of tenant A specific stuff
- this.contentTypeDelegate.doSomeContentTypeSpecificStuff();
- // do some more tenant A stuff
- this.contentTypeDelegate.doSomeOtherContentTypeSpecificStuff();
- }
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement