コード例 #1
0
        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;
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 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;
 }
コード例 #4
0
 public IActionBehavior BuildBehavior(ServiceArguments arguments, Guid behaviorId)
 {
     return _container.GetInstance<IActionBehavior>(arguments.ToExplicitArgs(), behaviorId.ToString());
 }
コード例 #5
0
 public IActionBehavior BuildBehavior(ServiceArguments arguments, Guid behaviorId)
 {
     return(_container.GetInstance <IActionBehavior>(arguments.ToExplicitArgs(), behaviorId.ToString()));
 }
コード例 #6
0
 public NestedStructureMapContainerBehavior(IContainer container, ServiceArguments arguments, Guid behaviorId)
 {
     _container = container;
     _arguments = arguments.ToExplicitArgs();
     _behaviorId = behaviorId;
 }
コード例 #7
0
        private void invokeRequestedBehavior(IContainer c)
        {
            var behavior = c.GetInstance <IActionBehavior>(_arguments.ToExplicitArgs(), _behaviorId.ToString());

            behavior.Invoke();
        }
コード例 #8
0
 public NestedStructureMapContainerBehavior(IContainer container, ServiceArguments arguments, Guid behaviorId)
 {
     _container  = container;
     _arguments  = arguments.ToExplicitArgs();
     _behaviorId = behaviorId;
 }
コード例 #9
0
        public T Build <T>(ServiceArguments arguments)
        {
            var explicitArguments = arguments.ToExplicitArgs();

            return(Container.GetInstance <T>(explicitArguments));
        }
コード例 #10
0
 public T Build <T>(ServiceArguments arguments)
 {
     return(Container.GetInstance <T>(arguments.ToExplicitArgs()));
 }