public bool Invoke(Action invokeMvcPipeline, ActionDescriptor actionDescriptor, ControllerContext controllerContext) { //IMvcActionInvoker is httpcontext scoped var mvcActionInvoker = _mvcActionInvokerResolver(); mvcActionInvoker.Set(invokeMvcPipeline); var actionName = _actionNameProvider.GetName(actionDescriptor); //find uniqueId for behavior chain that corresponds to this action call var controllerType = controllerContext.Controller.GetType(); var parameterDescriptors = actionDescriptor.GetParameters(); var inputParameters = parameterDescriptors.ToDictionary(x => x.ParameterName, x => x.ParameterType); var uniqueId = _behaviorChainIdLookup.GetUniqueId(controllerType, actionName, inputParameters); //get the behavior chain and invoke it, using this instance of ControllerContext for it var arguments = new ServiceArguments(); //provide controller context to any behaviors that need to get at it arguments.Set(typeof(ControllerContext), controllerContext); using (var nestedContainer = _container.GetNestedContainer()) { var actionBehavior = nestedContainer.GetInstance<IActionBehavior>(arguments.ToExplicitArgs(), uniqueId.ToString()); actionBehavior.Invoke(); } return true; }
public void Invoke() { using (var nested = _container.GetNestedContainer()) { nested.Configure(cfg => _arguments.EachService((type, value) => cfg.For(type).Use(value))); var request = nested.GetInstance <IFubuRequest>().Get <CurrentRequest>(); if (request.Url.StartsWith("/_content")) { nested.GetInstance <IActionBehavior>(_arguments.ToExplicitArgs(), _behaviorId.ToString()).Invoke(); return; } nested.ExecuteInTransactionWithoutNestedContainer <IContainer>(invokeRequestedBehavior); } }
protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType) { Controller result = null; if (controllerType != null) { var arguments = new ServiceArguments(); arguments.Set(typeof (ControllerContext), null); result = (Controller) _container.GetInstance(controllerType, arguments.ToExplicitArgs()); result.ActionInvoker = _container.GetInstance<IActionInvoker>(); } return result; }
public IActionBehavior BuildBehavior(ServiceArguments arguments, Guid behaviorId) { return _container.GetInstance<IActionBehavior>(arguments.ToExplicitArgs(), behaviorId.ToString()); }
public IActionBehavior BuildBehavior(ServiceArguments arguments, Guid behaviorId) { return(_container.GetInstance <IActionBehavior>(arguments.ToExplicitArgs(), behaviorId.ToString())); }
public NestedStructureMapContainerBehavior(IContainer container, ServiceArguments arguments, Guid behaviorId) { _container = container; _arguments = arguments.ToExplicitArgs(); _behaviorId = behaviorId; }
private void invokeRequestedBehavior(IContainer c) { var behavior = c.GetInstance <IActionBehavior>(_arguments.ToExplicitArgs(), _behaviorId.ToString()); behavior.Invoke(); }
public T Build <T>(ServiceArguments arguments) { var explicitArguments = arguments.ToExplicitArgs(); return(Container.GetInstance <T>(explicitArguments)); }
public T Build <T>(ServiceArguments arguments) { return(Container.GetInstance <T>(arguments.ToExplicitArgs())); }