Created
November 2, 2011 13:25
-
-
Save jimmyp/1333613 to your computer and use it in GitHub Desktop.
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 static class UselessStatefulScope // ;) | |
{ | |
public static void ProcessRequest<T>(T Request) | |
{ | |
//Resolve the validator & validate the request | |
var valid = Container.Resolve<IValidate<T>>(); | |
if(!valid(Request)) | |
throw new Exception(); | |
//Resolve all the applicable processors and process them | |
var processors = Container.ResolveAll<IProcess<T>>(); | |
foreach(processor in processors) | |
processor.process(Request, report); | |
} | |
} | |
//Then if we consider that reporting needs to be done on some processors one that did would look like this | |
public ProcessThatReportsItsProgress : IProcess<T> where T : Request | |
{ | |
public ProcessThatReportsProgress(IReportOn<T> reporter) | |
{ | |
Reporter = reporter; | |
} | |
IReportOn<T> Reporter; | |
public void process(T) | |
{ | |
//unique behaviour here | |
Reporter.Report(this); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment