Created
          April 30, 2012 03:11 
        
      - 
      
- 
        Save jmarnold/2555163 to your computer and use it in GitHub Desktop. 
    SampleProjection 
  
        
  
    
      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
    
  
  
    
  | 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)) | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Awesomeness :)