Created
October 20, 2011 19:10
-
-
Save rauhryan/1302008 to your computer and use it in GitHub Desktop.
This file contains 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
//////////////////Behavior | |
public class TransactionalContainerBehavior : IActionBehavior | |
{ | |
private readonly IContainer _container; | |
private readonly ServiceArguments _arguments; | |
private readonly Guid _behaviorId; | |
public TransactionalContainerBehavior(IContainer container, ServiceArguments arguments, Guid behaviorId) | |
{ | |
_container = container; | |
_arguments = arguments; | |
_behaviorId = behaviorId; | |
} | |
public void Invoke() | |
{ | |
var token = _container.GetInstance<IFubuRequest>().Get<TokenRequest>(); | |
/// what is token.Token? | |
InvokeRequestedBehavior(c); | |
} | |
public void InvokePartial(){} | |
private void InvokeRequestedBehavior(IContainer c) | |
{ | |
var behavior = c.GetInstance<IActionBehavior>(_arguments.ToExplicitArgs(), _behaviorId.ToString()); | |
behavior.Invoke(); | |
} | |
} | |
////////////////// Model Bound Class | |
public class TokenRequest | |
{ | |
public string Token {get; set; } | |
} | |
////////////////// Facility | |
public class RestAPIContainerFacility : StructureMapContainerFacility | |
{ | |
private readonly IContainer _container; | |
public RestAPIContainerFacility(IContainer container) | |
: base(container) | |
{ | |
_container = container; | |
} | |
public override FubuMVC.Core.Behaviors.IActionBehavior BuildBehavior(FubuCore.Binding.ServiceArguments arguments, Guid behaviorId) | |
{ | |
return new TransactionalContainerBehavior(_container, arguments, behaviorId); | |
} | |
} | |
/////////////////////// USAGE | |
FubuApplication | |
.For<RestApiFubuRegistry>() | |
.ContainerFacility(new RestAPIContainerFacility(ObjectFactory.Container)) | |
.Bootstrap(RouteTable.Routes); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment