Created
August 13, 2012 00:37
-
-
Save shanefulmer/3335824 to your computer and use it in GitHub Desktop.
Handler 3
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 ISomeTextService { string DoSomething(); } | |
public class SomeTextService : ISomeTextService { public string DoSomething() { return string.Empty; } } | |
public interface ISomeHtmlService { string DoSomethingElse(); } | |
public class SomeHtmlService : ISomeHtmlService { public string DoSomethingElse() { return string.Empty; } } | |
public enum RenderType {Text, Html} | |
public class Foo | |
{ | |
private readonly ISomeTextService _someTextService; | |
private readonly ISomeHtmlService _someHtmlService; | |
public Foo(ISomeTextService someTextService, ISomeHtmlService someHtmlService) | |
{ | |
_someTextService = someTextService; | |
_someHtmlService = someHtmlService; | |
} | |
public string Render(RenderType renderType) | |
{ | |
if (renderType == RenderType.Text) | |
return "this is a foo" + _someTextService.DoSomething(); | |
if (renderType == RenderType.Html) | |
return "<span>this is a foo</span>" + _someHtmlService.DoSomethingElse(); | |
throw new NotImplementedException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment