Skip to content

Instantly share code, notes, and snippets.

@jmarnold
Created April 30, 2012 03:11
Show Gist options
  • Save jmarnold/2555163 to your computer and use it in GitHub Desktop.
Save jmarnold/2555163 to your computer and use it in GitHub Desktop.
SampleProjection
public class SampleProjection : Projection<MyModel>
{
public SampleProjection()
: base(DisplayFormatting.UseDisplayFormatting)
{
// mapping properties here. the values are sent through IDisplayFormatter for all the conventional goodness
Value(x => x.BlockNr);
// Value... It's on our TODO list to do conventional mappings. It's all there just need to do it (e.g., IncludeImmediateProperties())
Value(x => x.LeadingTimestamp.Key).Name("Leading"); // when the name of the property doesn't sit well with you
ForAttribute("makingThisUpOnTheSpot").Use(ctx =>
{
var service = ctx.Service<SomeService>(); // pull something out of the nested container
return service.GetSomething(ctx.Subject.BlockNr); // use the Subject property to grab the instance of the class you're projecting
});
// I love this one
Value(x => x.Id).Name("someUrl").WriteUrlFor(id => new InputModelOfSomething(id))
}
}
@ahjohannessen
Copy link

Awesomeness :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment