Example #1
0
        public static T GetService <T>(this HttpActionExecutedContext context)
        {
            var scope     = context.Request.GetDependencyScope();
            var container = scope.GetService <IContainer>();

            var explicitArguments = new ExplicitArguments();

            explicitArguments.SetWithActualType(context);
            explicitArguments.SetWithActualType(context.ActionContext);
            explicitArguments.SetWithActualType(context.Response);

            return(container.GetInstance <T>(explicitArguments));
        }
Example #2
0
        public static T GetService <T>(this HttpActionContext context)
        {
            var scope     = context.Request.GetDependencyScope();
            var container = scope.GetService <IContainer>();

            var explicitArguments = new ExplicitArguments();

            explicitArguments.SetWithActualType(context);
            explicitArguments.SetWithActualType(context.ActionDescriptor);
            explicitArguments.SetWithActualType(context.ControllerContext);
            explicitArguments.SetWithActualType(context.ModelState);

            return(container.GetInstance <T>(explicitArguments));
        }