Skip to content

Instantly share code, notes, and snippets.

@duarten
Created February 25, 2011 00:15
Show Gist options
  • Save duarten/843182 to your computer and use it in GitHub Desktop.
Save duarten/843182 to your computer and use it in GitHub Desktop.
An WCF HTTP configuration DSL
static IProcessorProvider GetProcessorProvider()
{
return new ProcessorProviderFor<TheService>()
.RemoveDefaultMediaTypeProcessors()
.OnAllOperations(_ => _
.Use(typeof(DataValidationProcessor))
.UseForRequests(typeof(RequestLoggingProcessor)))
.OnGetOperation(_ => _
.UseForResponses(typeof(ImageFromTextMediaProcessor),
typeof(WaveFromTextMediaProcessor)))
.OnOperation(o => o.GetTime(default(HttpRequestMessage),
default(HttpResponseMessage)), _ => _
.UseForRequests((o, l, m) => new JsonProcessor(o, m)));
}
static IProcessorProvider GetProcessorProvider2()
{
return new ProcessorProviderFor<TheService>()
.RemoveDefaultMediaTypeProcessors()
.OnAllOperations(() =>
Use.ForRequestsAndResponses(typeof(DataValidationProcessor))
.ForRequests(typeof(RequestLoggingProcessor)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment