Created
February 24, 2011 17:25
-
-
Save pmhsfelix/842495 to your computer and use it in GitHub Desktop.
Experimentations with WCF HTTP configuration DSLs (take 2)
This file contains hidden or 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
static HttpHostConfiguration GetConfig2() | |
{ | |
var provider = new ProcessorProviderOf<TheService>() | |
.RemoveDefaultMediaTypeProcessors() | |
.ForAllOperations() | |
.UseRequestProcessors( | |
(o,l,m) => new DataValidationProcessor(o), | |
(o,l,m) => new RequestLoggingProcessor(o) | |
) | |
.And() | |
.ForOperation(s => s.GetTimeWithConneg2(default(HttpRequestMessage), default(HttpResponseMessage))) | |
.UseResponseProcessors( | |
(o, l, m) => new ImageFromTextMediaProcessor(o, m), | |
(o, l, m) => new WaveFromTextMediaProcessor(o, m)) | |
.And() | |
.ForOperation(s => s.GetZones(default(HttpRequestMessage), default(HttpResponseMessage))) | |
.UseResponseProcessors( | |
(o, l, m) => new XmlProcessor(o, m), | |
(o, l, m) => new JsonProcessor(o, m), | |
(o, l, m) => new AtomMediaTypeProcessor(o, m) | |
.WithFormatter( | |
(TheService.TimeZoneListModel tzms) => | |
new SyndicationFeed("Time zones", "List of time zones", null, | |
tzms.Zones.Select( | |
tzm => | |
new SyndicationItem(tzm.Id, tzm.Name, | |
new Uri(tzm.Uri))))) | |
); | |
return new HttpHostConfiguration().SetProcessorProvider(provider); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment