Created
May 23, 2010 21:43
-
-
Save NeilRobbins/411269 to your computer and use it in GitHub Desktop.
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
// So the question is - how would I configure OpenRasta to enable the below, where a real-world URI might look like (and any number of FooId | |
// arguments may be supplied): | |
// /queries/FooReportResource?LastReportDate=2010-05-23Z&ApplicableFoos=FooId1,FooId2,FooId3,FooId4 | |
public class Configuration : IConfigurationSource | |
{ | |
public void Configure() | |
{ | |
using (OpenRastaConfiguration.Manual) | |
{ | |
ResourceSpace.Has.ResourcesOfType<FooReportResource>() | |
.AtUri("/queries/FooReportResource?LastReportDate={FooReportSpecification.lastReportDate}&ApplicableFoos= | |
{FooReportSpecification.ApplicableFoos}") | |
.HandledBy<FooReportResourceHandler>() | |
.AsXmlDataContract(); | |
} | |
} | |
} | |
public class FooReportResourceHandler | |
{ | |
public FooReportResource Get(FooReportSpecification specification) | |
{ | |
... | |
} | |
} | |
// where Foo is a category identified by a FooIdentifier | |
public class FooReportSpecification | |
{ | |
private readonly DateTime _lastReportDate; | |
private readonly IEnumerable<FooIdentifier> _applicableFoos; | |
public FooReportSpecification(DateTime lastReportDate, IEnumerable<FooIdentifier> applicableFoos) | |
{ | |
_lastReportDate = lastReportDate; | |
_applicableFoos = applicableFoos; | |
} | |
public IEnumerable<FooIdentifier> ApplicableFoos | |
{ | |
get { return _applicableFoos; } | |
} | |
public DateTime LastReportDate | |
{ | |
get { return _lastReportDate; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment