Created
March 23, 2012 19:05
-
-
Save pedroreys/2173894 to your computer and use it in GitHub Desktop.
WebAPIContrib Transitions
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 interface IApiResource { | |
void SetLocation(ResourceLocation resourceLocation); | |
void SetTransitions(ResourceTransitions transitions); | |
} | |
public class Order : IApiResource { | |
public int Id { get; set; } | |
// other resource members ... | |
public void SetLocation(ResourceLocation resourceLocation) { | |
resourceLocation.SetInController<OrdersController>(x => x.Get(this.Id)); | |
} | |
public void SetTransitions(ResourceTransitions transitions) { | |
transitions.Add<PaymentController>("pay", x => x.Post()); | |
transitions.Add<OrderController>("cancel", x=> x.DeleteOrder()); | |
transitions.Add("foo", new Uri("http://foobar.com")); | |
} | |
} | |
// With that I can have IApiResource aware formatters that would know what to do with the transitions and generate the links accordingly. | |
// How does this looks to you? Does it align with your idea of the link generation helpers? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment