Skip to content

Instantly share code, notes, and snippets.

@shanefulmer
Created August 13, 2012 00:37
Show Gist options
  • Save shanefulmer/3335824 to your computer and use it in GitHub Desktop.
Save shanefulmer/3335824 to your computer and use it in GitHub Desktop.
Handler 3
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