Skip to content

Instantly share code, notes, and snippets.

@shanefulmer
Created August 13, 2012 01:06
Show Gist options
  • Save shanefulmer/3336101 to your computer and use it in GitHub Desktop.
Save shanefulmer/3336101 to your computer and use it in GitHub Desktop.
Handler 4
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 interface IRenderer<T> { string Render(T obj); }
public class FooTextRenderer : IRenderer<Foo>
{
private readonly ISomeTextService _someTextService;
public FooTextRenderer(ISomeTextService someTextService) { _someTextService = someTextService; }
public string Render(Foo foo)
{
return "this is a foo" + _someTextService.DoSomething();
}
}
public class FooHtmlRenderer : IRenderer<Foo>
{
private readonly ISomeHtmlService _someHtmlService;
public FooHtmlRenderer(ISomeHtmlService someHtmlService) { _someHtmlService = someHtmlService; }
public string Render(Foo foo)
{
return "this is a foo" + _someHtmlService.DoSomethingElse();
}
}
public class Foo
{
// foo domain logic
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment