Skip to content

Instantly share code, notes, and snippets.

@jimmyp
Created November 2, 2011 13:25
Show Gist options
  • Save jimmyp/1333614 to your computer and use it in GitHub Desktop.
Save jimmyp/1333614 to your computer and use it in GitHub Desktop.
corrected generic type of ProcessThatReportsItsProgress
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<ProcessThatReportsItsProgress> 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