Skip to content

Instantly share code, notes, and snippets.

@NeilRobbins
Created May 23, 2010 21:43
Show Gist options
  • Save NeilRobbins/411269 to your computer and use it in GitHub Desktop.
Save NeilRobbins/411269 to your computer and use it in GitHub Desktop.
// 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