コード例 #1
0
            public override void Given()
            {
                var fluentMvcObjectFactory = CreateStub <IFluentMvcObjectFactory>();

                fluentMvcObjectFactory.Stub(x => x.Resolve <object>(Arg <Type> .Is.Anything)).Return(new TestFilter());

                actionFilterRegistry = new ActionFilterRegistry(fluentMvcObjectFactory);
                globalFilter         = new GlobalActionFilterRegistryItem(typeof(TestActionFilter), PredefinedConstraint.True);

                Expression <Func <TestController, object> > func = c => c.ReturnPost();

                actionDescriptor = func.CreateActionDescriptor();

                controllerFilterItem       = new ControllerRegistryItem(typeof(TestActionFilter3), PredefinedConstraint.True, actionDescriptor.ControllerDescriptor);
                controllerActionFilterItem = new ControllerActionRegistryItem(typeof(TestActionFilter2),
                                                                              PredefinedConstraint.True,
                                                                              actionDescriptor,
                                                                              actionDescriptor.ControllerDescriptor);

                actionFilterRegistry.Add(globalFilter);
                actionFilterRegistry.Add(controllerFilterItem);
                actionFilterRegistry.Add(controllerActionFilterItem);

                resolver = new ActionFilterResolver(actionFilterRegistry, fluentMvcObjectFactory);
            }
コード例 #2
0
 public override void Given()
 {
     objectFactory        = CreateStub <IFluentMvcObjectFactory>();
     actionFilterRegistry = CreateStub <IActionFilterRegistry>();
     Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                            .ResolveWith(objectFactory)
                            .WithResultFactory <JsonResultFactory>();
 }
コード例 #3
0
 public override void Given()
 {
     Expression<Func<TestController, object>> func = c => c.ReturnPost();
     actionDescriptor = func.CreateActionDescriptor();
     actionFilterRegistry = new ActionFilterRegistry(CreateStub<IFluentMvcObjectFactory>());
     Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
         .WithFilter<TestActionFilter>();
 }
コード例 #4
0
 private FluentMvcConfiguration(IFluentMvcResolver fluentMvcResolver, IActionFilterRegistry actionFilterRegistry, IActionResultRegistry actionResultRegistry, IFilterConventionCollection filterConventionCollection)
     : this()
 {
     this.fluentMvcResolver    = fluentMvcResolver;
     this.actionResultRegistry = actionResultRegistry;
     this.actionFilterRegistry = actionFilterRegistry;
     FilterConventions         = filterConventionCollection;
 }
コード例 #5
0
 public override void Given()
 {
     objectFactory = CreateStub<IFluentMvcObjectFactory>();
     actionFilterRegistry = CreateStub<IActionFilterRegistry>();
     Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
         .ResolveWith(objectFactory)
         .WithResultFactory<JsonResultFactory>();
 }
コード例 #6
0
        public override void Given()
        {
            Expression <Func <TestController, object> > func = c => c.ReturnPost();

            actionDescriptor     = func.CreateActionDescriptor();
            actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                   .WithFilter <TestActionFilter>();
        }
コード例 #7
0
        public override void Given()
        {
            fluentMvcResolver          = CreateStub <IFluentMvcResolver>();
            actionFilterRegistry       = CreateStub <IActionFilterRegistry>();
            actionResultRegistry       = CreateStub <IActionResultRegistry>();
            filterConventionCollection = CreateStub <IFilterConventionCollection>();

            Configuration = FluentMvcConfiguration
                            .Create(fluentMvcResolver, actionFilterRegistry, actionResultRegistry, filterConventionCollection);
        }
コード例 #8
0
 public override void Given()
 {
     actionFilterRegistry = new ActionFilterRegistry(CreateStub<IFluentMvcObjectFactory>());
     Expression<Func<TestController, object>> func = controller => controller.ReturnPost();
     Expression<Func<TestController, object>> otherFunc = controller => controller.ReturnViewResult();
     actionDescriptor = func.CreateActionDescriptor();
     incorrectActionDescriptor = otherFunc.CreateActionDescriptor();
     Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
         .WithFilter<TestActionFilter>(Apply.For<TestController>().ExceptFor(otherFunc));
 }
コード例 #9
0
        public override void Given()
        {
            actionFilter = new TestActionFilter();
            objectFactory = CreateStub<IFluentMvcObjectFactory>();
            objectFactory.Stub(of => of.Resolve<IActionFilter>(Arg<Type>.Is.Anything))
                .Return(actionFilter);

            actionFilterRegistry = new ActionFilterRegistry(objectFactory);
            actionFilterRegistryTester = new ActionFilterRegistryTester(actionFilterRegistry);
        }
コード例 #10
0
        public override void Given()
        {
            actionFilter  = new TestActionFilter();
            objectFactory = CreateStub <IFluentMvcObjectFactory>();
            objectFactory.Stub(of => of.Resolve <IActionFilter>(Arg <Type> .Is.Anything))
            .Return(actionFilter);

            actionFilterRegistry       = new ActionFilterRegistry(objectFactory);
            actionFilterRegistryTester = new ActionFilterRegistryTester(actionFilterRegistry);
        }
コード例 #11
0
        public override void Given()
        {
            actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Expression <Func <SecondTestController, object> > func          = controller => controller.ReturnPost();
            Expression <Func <TestController, object> >       exceptForFunc = controller => controller.ReturnViewResult();

            actionDescriptor          = func.CreateActionDescriptor();
            exceptforActionDescriptor = exceptForFunc.CreateActionDescriptor();
            Configuration             = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                        .WithFilter <TestActionFilter>(Apply.For <SecondTestController>().ExceptFor(exceptForFunc));
        }
コード例 #12
0
        public override void Given()
        {
            Expression <Func <TestController, object> >       func  = c => c.ReturnPost();
            Expression <Func <SecondTestController, object> > func2 = c => c.ReturnPost();
            Expression <Func <ThirdTestController, object> >  func3 = c => c.ReturnPost();

            actionDescriptor       = func.CreateActionDescriptor();
            secondActionDescriptor = func2.CreateActionDescriptor();
            thirdActionDescriptor  = func3.CreateActionDescriptor();
            actionFilterRegistry   = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Configuration          = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                     .WithFilter <AuthorizeAttribute>(Except.For <TestController>().AndFor <ThirdTestController>());
        }
コード例 #13
0
        public override void Given()
        {
            actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
            Expression <Func <TestController, object> > func      = controller => controller.ReturnPost();
            Expression <Func <TestController, object> > otherFunc = controller => controller.ReturnViewResult();

            actionDescriptor          = func.CreateActionDescriptor();
            incorrectActionDescriptor = otherFunc.CreateActionDescriptor();
            Configuration             = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                        .WithFilter <TestActionFilter>(Except.For <SecondTestController>().AndFor <TestController>(func).AndFor <TestController>(t => t.ReturnNull()));

            registryTester = new ActionFilterRegistryTester(actionFilterRegistry);
        }
コード例 #14
0
        public void Execute(IDictionary <string, object> state)
        {
            IActionFilterRegistry actionFilterRegistry = container.Resolve <ActionFilterRegistry>();

            actionFilterRegistry.Clear();

            container.Resolve <IRegisterActionFilters>().RegisterFilters(actionFilterRegistry);

            foreach (IRegisterActionFilters actionFilters in container.ResolveAll <IRegisterActionFilters>())
            {
                actionFilters.RegisterFilters(actionFilterRegistry);
            }

            container.RegisterInstance(actionFilterRegistry);
        }
            public override void Given()
            {
                actionFilterRegistry = new ActionFilterRegistry(CreateStub<IFluentMvcObjectFactory>());
                Expression<Func<TestController, object>> func = controller => controller.ReturnNull();
                Expression<Func<TestController, object>> otherFunc = controller => controller.ReturnNull(null);

                var proxyGenerator = new ProxyGenerator();
                var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy<TestController>();

                var controllerType = interfaceProxyWithTarget.GetType();

                var methodInfos = controllerType.GetMethods();
                actionDescriptor = new ReflectedActionDescriptor(methodInfos.First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0), "ReturnNull", new ReflectedControllerDescriptor(controllerType));

                Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
                    .WithFilter<TestActionFilter>(Apply.For(func).AndFor(otherFunc));
            }
コード例 #16
0
            public override void Given()
            {
                actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
                Expression <Func <TestController, object> > func      = controller => controller.ReturnNull();
                Expression <Func <TestController, object> > otherFunc = controller => controller.ReturnNull(null);

                var proxyGenerator           = new ProxyGenerator();
                var interfaceProxyWithTarget = proxyGenerator.CreateClassProxy <TestController>();

                var controllerType = interfaceProxyWithTarget.GetType();

                var methodInfos = controllerType.GetMethods();

                actionDescriptor = new ReflectedActionDescriptor(methodInfos.First(x => x.Name.Equals("ReturnNull") && x.GetParameters().Count() == 0), "ReturnNull", new ReflectedControllerDescriptor(controllerType));

                Configuration = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                .WithFilter <TestActionFilter>(Apply.For(func).AndFor(otherFunc));
            }
コード例 #17
0
        public override void Given()
        {
            Expression <Func <TestController, object> >       func  = c => c.ReturnPost();
            Expression <Func <SecondTestController, object> > func2 = c => c.ReturnPost();
            Expression <Func <ThirdTestController, object> >  func3 = c => c.ReturnPost();

            actionDescriptor         = func.CreateActionDescriptor();
            secondActionDescriptor   = func2.CreateActionDescriptor();
            excludedActionDescriptor = func3.CreateActionDescriptor();

            fluentMvcObjectFactory = CreateStub <IFluentMvcObjectFactory>();
            fluentMvcObjectFactory.Stub(x => x.Resolve <object>(Arg <Type> .Is.Anything)).Return(CreateStub <IActionFilter>());

            actionFilterRegistry = new ActionFilterRegistry(fluentMvcObjectFactory);
            Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                                   .WithFilter <AcceptVerbsAttribute>()
                                   .WithFilter <AuthorizeAttribute>(Except.For <TestController>().AndFor(func3));

            resolver = new ActionFilterResolver(actionFilterRegistry, fluentMvcObjectFactory);
        }
コード例 #18
0
ファイル: Global.asax.cs プロジェクト: a864610877/src
        private void registerActionFilters()
        {
            IUnityContainer       container = getContainer();
            IActionFilterRegistry registry  = container.Resolve <ActionFilterRegistry>();

            registry.Clear();

            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(AntiForgeryActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(SiteInfoActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(MenusActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(BuildUpActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(ContainerActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(UserActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(AntiForgeryAuthorizationFilter));

            registry.Add(new[] { new DataFormatCriteria("RSS") }, typeof(RssResultActionFilter));
            registry.Add(new[] { new DataFormatCriteria("ATOM") }, typeof(AtomResultActionFilter));
            registry.Add(new[] { new RequestCriteria("excel"), }, typeof(ExcelResultActionFilter));

            //只有包含以下方法的 action 才能使用 PageSizeFilter 和 ArchiveListActionFilter
            ControllerActionCriteria listActionsCriteria = new ControllerActionCriteria();

            registry.Add(new[] { listActionsCriteria }, typeof(PageSizeActionFilter));



            ControllerActionCriteria adminActionsCriteria = new ControllerActionCriteria();

            //adminActionsCriteria.AddMethod<SiteController>(s => s.Dashboard());
            //adminActionsCriteria.AddMethod<SiteController>(s => s.Item());
            //TODO: (erikpo) Once we have roles other than "authenticated" this should move to not be part of the admin, but just part of authed users
            //adminActionsCriteria.AddMethod<MembershipController>(u => u.ChangePassword());
            registry.Add(new[] { adminActionsCriteria }, typeof(AuthorizationFilter));

            //TODO: (erikpo) Once we have the plugin model completed, load up all available action filter criteria into the registry here instead of hardcoding them.

            container.RegisterInstance(registry);
        }
コード例 #19
0
            public override void Given()
            {
                var fluentMvcObjectFactory = CreateStub<IFluentMvcObjectFactory>();
                fluentMvcObjectFactory.Stub(x => x.Resolve<object>(Arg<Type>.Is.Anything)).Return(new TestFilter());

                actionFilterRegistry = new ActionFilterRegistry(fluentMvcObjectFactory);
                globalFilter = new GlobalActionFilterRegistryItem(typeof(TestActionFilter), PredefinedConstraint.True);

                Expression<Func<TestController, object>> func = c => c.ReturnPost();
                actionDescriptor = func.CreateActionDescriptor();

                controllerFilterItem = new ControllerRegistryItem(typeof(TestActionFilter3), PredefinedConstraint.True, actionDescriptor.ControllerDescriptor);
                controllerActionFilterItem = new ControllerActionRegistryItem(typeof(TestActionFilter2),
                                                                          PredefinedConstraint.True,
                                                                          actionDescriptor,
                                                                          actionDescriptor.ControllerDescriptor);

                actionFilterRegistry.Add(globalFilter);
                actionFilterRegistry.Add(controllerFilterItem);
                actionFilterRegistry.Add(controllerActionFilterItem);

                resolver = new ActionFilterResolver(actionFilterRegistry, fluentMvcObjectFactory);
            }
コード例 #20
0
        private void registerActionFilters()
        {
            IUnityContainer       container = getContainer();
            IActionFilterRegistry registry  = container.Resolve <ActionFilterRegistry>();

            registry.Clear();

            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(AntiForgeryActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(SiteInfoActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(UserActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(LocalizationActionFilter));
            registry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(AntiForgeryAuthorizationFilter));

            registry.Add(new[] { new DataFormatCriteria("RSS") }, typeof(RssResultActionFilter));
            registry.Add(new[] { new DataFormatCriteria("ATOM") }, typeof(AtomResultActionFilter));

            ControllerActionCriteria listActionsCriteria = new ControllerActionCriteria();

            listActionsCriteria.AddMethod <AreaController>(a => a.Find());
            listActionsCriteria.AddMethod <AreaController>(a => a.FindQuery(null));
            listActionsCriteria.AddMethod <AreaController>(a => a.BlogML(null));
            listActionsCriteria.AddMethod <AreaController>(a => a.BlogMLSave(null, null, null));
            listActionsCriteria.AddMethod <CommentController>(c => c.List(0, 0));
            listActionsCriteria.AddMethod <PostController>(p => p.List(null, 0, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListByArchive(0, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListByArea(null, 0, null, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListBySearch(null, 0, null, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListByTag(null, 0, null, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListWithDrafts(null, 0));
            registry.Add(new[] { listActionsCriteria }, typeof(ArchiveListActionFilter));
            registry.Add(new[] { listActionsCriteria }, typeof(PageSizeActionFilter));

            ControllerActionCriteria itemActionCriteria = new ControllerActionCriteria();

            itemActionCriteria.AddMethod <PostController>(p => p.Item(null, null));
            itemActionCriteria.AddMethod <PostController>(p => p.AddComment(null, null, null, null, null, null, null));
            registry.Add(new[] { itemActionCriteria }, typeof(CommentingDisabledActionFilter));

            ControllerActionCriteria tagCloudActionCriteria = new ControllerActionCriteria();

            tagCloudActionCriteria.AddMethod <TagController>(t => t.Cloud());
            registry.Add(new[] { tagCloudActionCriteria }, typeof(ArchiveListActionFilter));

            ControllerActionCriteria areaListActionCriteria = new ControllerActionCriteria();

            areaListActionCriteria.AddMethod <PostController>(p => p.Add(null, null));
            areaListActionCriteria.AddMethod <PostController>(p => p.SaveAdd(null, null, null));
            areaListActionCriteria.AddMethod <PostController>(p => p.Edit(null, null));
            areaListActionCriteria.AddMethod <PostController>(p => p.SaveEdit(null, null, null));
            registry.Add(new[] { areaListActionCriteria }, typeof(AreaListActionFilter));

            ControllerActionCriteria pageListActionCriteria = new ControllerActionCriteria();

            pageListActionCriteria.AddMethod <PageController>(p => p.Add(null));
            pageListActionCriteria.AddMethod <PageController>(p => p.SaveAdd(null, null, null));
            pageListActionCriteria.AddMethod <PageController>(p => p.Edit(null));
            pageListActionCriteria.AddMethod <PageController>(p => p.SaveEdit(null, null, null));
            registry.Add(new[] { pageListActionCriteria }, typeof(PageListActionFilter));

            ControllerActionCriteria adminActionsCriteria = new ControllerActionCriteria();

            adminActionsCriteria.AddMethod <AreaController>(a => a.Find());
            adminActionsCriteria.AddMethod <AreaController>(a => a.FindQuery(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.ItemEdit(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.ItemSave(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.BlogML(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.BlogMLSave(null, null, null));
            adminActionsCriteria.AddMethod <CommentController>(c => c.List(0, 0));
            adminActionsCriteria.AddMethod <CommentController>(c => c.Remove(null, null, null, null));
            adminActionsCriteria.AddMethod <CommentController>(c => c.Approve(null, null, null, null));
            adminActionsCriteria.AddMethod <PageController>(p => p.Add(null));
            adminActionsCriteria.AddMethod <PageController>(p => p.SaveAdd(null, null, null));
            adminActionsCriteria.AddMethod <PageController>(p => p.Edit(null));
            adminActionsCriteria.AddMethod <PageController>(p => p.SaveEdit(null, null, null));
            adminActionsCriteria.AddMethod <PageController>(p => p.Remove(null, null));
            adminActionsCriteria.AddMethod <PluginController>(p => p.List());
            adminActionsCriteria.AddMethod <PluginController>(p => p.Item(Guid.Empty));
            adminActionsCriteria.AddMethod <PostController>(p => p.Add(null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.SaveAdd(null, null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.Edit(null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.SaveEdit(null, null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.Remove(null, null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.ListWithDrafts(null, 0));
            adminActionsCriteria.AddMethod <SiteController>(s => s.Dashboard());
            if (container.Resolve <Site>().ID != Guid.Empty)
            {
                adminActionsCriteria.AddMethod <SiteController>(s => s.Item());
            }
            //TODO: (erikpo) Once we have roles other than "authenticated" this should move to not be part of the admin, but just part of authed users
            adminActionsCriteria.AddMethod <UserController>(u => u.ChangePassword(null));
            registry.Add(new[] { adminActionsCriteria }, typeof(AuthorizationFilter));

            ControllerActionCriteria dashboardDataActionCriteria = new ControllerActionCriteria();

            dashboardDataActionCriteria.AddMethod <SiteController>(s => s.Dashboard());
            registry.Add(new[] { dashboardDataActionCriteria }, typeof(DashboardDataActionFilter));

            //TODO: (erikpo) Once we have the plugin model completed, load up all available action filter criteria into the registry here instead of hardcoding them.

            container.RegisterInstance(registry);
        }
コード例 #21
0
 public void SetActionFilterRegistry(IActionFilterRegistry registry)
 {
     actionFilterRegistry = registry;
 }
コード例 #22
0
        public override void Given()
        {
            fluentMvcResolver = CreateStub<IFluentMvcResolver>();
            actionFilterRegistry = CreateStub<IActionFilterRegistry>();
            actionResultRegistry = CreateStub<IActionResultRegistry>();
            filterConventionCollection = CreateStub<IFilterConventionCollection>();

            Configuration = FluentMvcConfiguration
                .Create(fluentMvcResolver, actionFilterRegistry, actionResultRegistry, filterConventionCollection);
        }
コード例 #23
0
        public void RegisterFilters(IActionFilterRegistry actionFilterRegistry)
        {
            actionFilterRegistry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(SiteInfoActionFilter));
            actionFilterRegistry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(UserActionFilter));
            actionFilterRegistry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(LocalizationActionFilter));
            actionFilterRegistry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(AntiForgeryAuthorizationFilter));
            actionFilterRegistry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(SkinResultFilter));

            //TODO: (erikpo) Check a ViewTrackingEnabled Site setting to add this or not
            actionFilterRegistry.Add(Enumerable.Empty <IActionFilterCriteria>(), typeof(ViewTrackingResultFilter));

            actionFilterRegistry.Add(new[] { new DataFormatCriteria("RSS") }, typeof(RssResultActionFilter));
            actionFilterRegistry.Add(new[] { new DataFormatCriteria("ATOM") }, typeof(AtomResultActionFilter));

            ControllerActionCriteria listActionsCriteria = new ControllerActionCriteria();

            listActionsCriteria.AddMethod <AreaController>(a => a.Find());
            listActionsCriteria.AddMethod <AreaController>(a => a.FindQuery(null));
            listActionsCriteria.AddMethod <AreaController>(a => a.BlogML(null));
            listActionsCriteria.AddMethod <AreaController>(a => a.BlogMLSave(null, null, null));
            listActionsCriteria.AddMethod <CommentController>(c => c.List(0, 0));
            listActionsCriteria.AddMethod <PostController>(p => p.List(null, 0, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListByArchive(0, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListByArea(null, 0, null, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListBySearch(null, 0, null, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListByTag(null, 0, null, null));
            listActionsCriteria.AddMethod <PostController>(p => p.ListWithDrafts(null, 0));
            actionFilterRegistry.Add(new[] { listActionsCriteria }, typeof(ArchiveListActionFilter));
            actionFilterRegistry.Add(new[] { listActionsCriteria }, typeof(PageSizeActionFilter));

            ControllerActionCriteria itemActionCriteria = new ControllerActionCriteria();

            itemActionCriteria.AddMethod <PostController>(p => p.Item(null));
            itemActionCriteria.AddMethod <PostController>(p => p.AddComment(null, null, null, null, null, null));
            actionFilterRegistry.Add(new[] { itemActionCriteria }, typeof(CommentingDisabledActionFilter));

            ControllerActionCriteria tagCloudActionCriteria = new ControllerActionCriteria();

            tagCloudActionCriteria.AddMethod <TagController>(t => t.Cloud());
            actionFilterRegistry.Add(new[] { tagCloudActionCriteria }, typeof(ArchiveListActionFilter));

            ControllerActionCriteria areaListActionCriteria = new ControllerActionCriteria();

            areaListActionCriteria.AddMethod <PostController>(p => p.Add(null, null));
            areaListActionCriteria.AddMethod <PostController>(p => p.SaveAdd(null, null, null));
            areaListActionCriteria.AddMethod <PostController>(p => p.Edit(null));
            areaListActionCriteria.AddMethod <PostController>(p => p.SaveEdit(null, null));
            actionFilterRegistry.Add(new[] { areaListActionCriteria }, typeof(AreaListActionFilter));

            ControllerActionCriteria pageListActionCriteria = new ControllerActionCriteria();

            pageListActionCriteria.AddMethod <PageController>(p => p.Add(null));
            pageListActionCriteria.AddMethod <PageController>(p => p.SaveAdd(null, null, null));
            pageListActionCriteria.AddMethod <PageController>(p => p.Edit(null));
            pageListActionCriteria.AddMethod <PageController>(p => p.SaveEdit(null, null, null));
            actionFilterRegistry.Add(new[] { pageListActionCriteria }, typeof(PageListActionFilter));

            ControllerActionCriteria adminActionsCriteria = new ControllerActionCriteria();

            adminActionsCriteria.AddMethod <AreaController>(a => a.Find());
            adminActionsCriteria.AddMethod <AreaController>(a => a.FindQuery(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.ItemEdit(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.ItemSave(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.BlogML(null));
            adminActionsCriteria.AddMethod <AreaController>(a => a.BlogMLSave(null, null, null));
            adminActionsCriteria.AddMethod <CommentController>(c => c.List(0, 0));
            adminActionsCriteria.AddMethod <CommentController>(c => c.Remove(null, null, null));
            adminActionsCriteria.AddMethod <CommentController>(c => c.Approve(null, null, null));
            adminActionsCriteria.AddMethod <FileController>(f => f.ListByPost(null));
            adminActionsCriteria.AddMethod <FileController>(f => f.AddFileContentToPost(null, null, null));
            adminActionsCriteria.AddMethod <FileController>(f => f.AddFileToPost(null, null, null));
            adminActionsCriteria.AddMethod <FileController>(f => f.EditFileOnPost(null, null, null, null));
            adminActionsCriteria.AddMethod <FileController>(f => f.RemoveFileFromPost(null, null, null));
            adminActionsCriteria.AddMethod <PageController>(p => p.Add(null));
            adminActionsCriteria.AddMethod <PageController>(p => p.SaveAdd(null, null, null));
            adminActionsCriteria.AddMethod <PageController>(p => p.Edit(null));
            adminActionsCriteria.AddMethod <PageController>(p => p.SaveEdit(null, null, null));
            adminActionsCriteria.AddMethod <PageController>(p => p.Remove(null, null));
            adminActionsCriteria.AddMethod <PluginController>(p => p.List());
            adminActionsCriteria.AddMethod <PluginController>(p => p.Item(Guid.Empty));
            adminActionsCriteria.AddMethod <PostController>(p => p.Add(null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.SaveAdd(null, null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.Edit(null));
            adminActionsCriteria.AddMethod <PostController>(p => p.SaveEdit(null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.Remove(null, null));
            adminActionsCriteria.AddMethod <PostController>(p => p.ListWithDrafts(null, 0));
            adminActionsCriteria.AddMethod <SiteController>(s => s.Dashboard());
            adminActionsCriteria.AddMethod <SiteController>(s => s.Item());

            //TODO: (erikpo) Once we have roles other than "authenticated" this should move to not be part of the admin, but just part of authed users
            adminActionsCriteria.AddMethod <UserController>(u => u.ChangePassword(null));
            actionFilterRegistry.Add(new[] { adminActionsCriteria }, typeof(AuthorizationFilter));

            ControllerActionCriteria dashboardDataActionCriteria = new ControllerActionCriteria();

            dashboardDataActionCriteria.AddMethod <SiteController>(s => s.Dashboard());
            actionFilterRegistry.Add(new[] { dashboardDataActionCriteria }, typeof(DashboardDataActionFilter));
        }
コード例 #24
0
 public ActionFilterResolver(IActionFilterRegistry actionFilterRegistry, IFluentMvcObjectFactory fac)
 {
     this.actionFilterRegistry = actionFilterRegistry;
     this.fac = fac;
 }
コード例 #25
0
 public EcardControllerActionInvoker(IActionFilterRegistry registry, LogHelper logger)
 {
     this.registry = registry;
     Logger        = logger;
 }
コード例 #26
0
 public ActionFilterRegistryTester(IActionFilterRegistry actionFilterRegistry)
 {
     this.actionFilterRegistry = actionFilterRegistry;
 }
コード例 #27
0
        public override void Given()
        {
            actionFilterRegistry = new ActionFilterRegistry(CreateStub<IFluentMvcObjectFactory>());
            Expression<Func<SecondTestController, object>> func = controller => controller.ReturnPost();
            Expression<Func<TestController, object>> exceptForFunc = controller => controller.ReturnViewResult();
            actionDescriptor = func.CreateActionDescriptor();
            exceptforActionDescriptor = exceptForFunc.CreateActionDescriptor();
            Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
                .WithFilter<TestActionFilter>(Apply.When<TrueReturningConstraint>().ExceptFor(exceptForFunc));

            resolver = new ActionFilterResolver(actionFilterRegistry, CreateStub<IFluentMvcObjectFactory>());
        }
コード例 #28
0
 public static FluentMvcConfiguration Create(IFluentMvcResolver fluentMvcResolver, IActionFilterRegistry actionFilterRegistry, IActionResultRegistry actionResultRegistry, IFilterConventionCollection filterConventionCollection)
 {
     return(new FluentMvcConfiguration(fluentMvcResolver, actionFilterRegistry, actionResultRegistry, filterConventionCollection));
 }
コード例 #29
0
ファイル: FluentMvcResolver.cs プロジェクト: carcer/FluentMvc
 public void SetActionFilterRegistry(IActionFilterRegistry registry)
 {
     actionFilterResolver.SetActionFilterRegistry(registry);
 }
コード例 #30
0
 public override void Given()
 {
     actionFilterRegistry = new ActionFilterRegistry(CreateStub<IFluentMvcObjectFactory>());
     Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
         .WithFilter<TestActionFilter>(Apply.When<TrueReturningConstraint>());
 }
コード例 #31
0
 public override void Given()
 {
     Expression<Func<TestController, object>> func = c => c.ReturnPost();
     Expression<Func<SecondTestController, object>> func2 = c => c.ReturnPost();
     Expression<Func<ThirdTestController, object>> func3 = c => c.ReturnPost();
     actionDescriptor = func.CreateActionDescriptor();
     secondActionDescriptor = func2.CreateActionDescriptor();
     thirdActionDescriptor = func3.CreateActionDescriptor();
     actionFilterRegistry = new ActionFilterRegistry(CreateStub<IFluentMvcObjectFactory>());
     Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
         .WithFilter<AuthorizeAttribute>(Except.For<TestController>().AndFor<ThirdTestController>());
 }
コード例 #32
0
        public override void Given()
        {
            Expression<Func<TestController, object>> func = c => c.ReturnPost();
            Expression<Func<SecondTestController, object>> func2 = c => c.ReturnPost();
            Expression<Func<ThirdTestController, object>> func3 = c => c.ReturnPost();
            actionDescriptor = func.CreateActionDescriptor();
            secondActionDescriptor = func2.CreateActionDescriptor();
            excludedActionDescriptor = func3.CreateActionDescriptor();

            fluentMvcObjectFactory = CreateStub<IFluentMvcObjectFactory>();
            fluentMvcObjectFactory.Stub(x => x.Resolve<object>(Arg<Type>.Is.Anything)).Return(CreateStub<IActionFilter>());

            actionFilterRegistry = new ActionFilterRegistry(fluentMvcObjectFactory);
            Configuration = FluentMvcConfiguration.Create(CreateStub<IFluentMvcResolver>(), actionFilterRegistry, CreateStub<IActionResultRegistry>(), CreateStub<IFilterConventionCollection>())
                .WithFilter<AcceptVerbsAttribute>()
                .WithFilter<AuthorizeAttribute>(Except.For<TestController>().AndFor(func3));

            resolver = new ActionFilterResolver(actionFilterRegistry, fluentMvcObjectFactory);
        }
コード例 #33
0
 public override void Given()
 {
     actionFilterRegistry = new ActionFilterRegistry(CreateStub <IFluentMvcObjectFactory>());
     Configuration        = FluentMvcConfiguration.Create(CreateStub <IFluentMvcResolver>(), actionFilterRegistry, CreateStub <IActionResultRegistry>(), CreateStub <IFilterConventionCollection>())
                            .WithFilter <TestActionFilter>(Apply.When <TrueReturningConstraint>());
 }
コード例 #34
0
 public OxiteControllerActionInvoker(IActionFilterRegistry registry)
 {
     this.registry = registry;
 }
コード例 #35
0
 public void SetActionFilterRegistry(IActionFilterRegistry registry)
 {
     throw new System.NotImplementedException();
 }
コード例 #36
0
 public override void ForEach()
 {
     actionFilterRegistry = CreateStub <IActionFilterRegistry>();
     actionResultRegistry = CreateStub <IActionResultRegistry>();
 }
コード例 #37
0
ファイル: FluentMvcResolver.cs プロジェクト: carcer/FluentMvc
 public ActionFilterResolver(IActionFilterRegistry actionFilterRegistry, IFluentMvcObjectFactory fac)
 {
     this.actionFilterRegistry = actionFilterRegistry;
     this.fac = fac;
 }
コード例 #38
0
 public override void ForEach()
 {
     actionFilterRegistry = CreateStub<IActionFilterRegistry>();
     actionResultRegistry = CreateStub<IActionResultRegistry>();
 }
コード例 #39
0
 public void SetActionFilterRegistry(IActionFilterRegistry registry)
 {
     actionFilterResolver.SetActionFilterRegistry(registry);
 }
コード例 #40
0
ファイル: FluentMvcResolver.cs プロジェクト: carcer/FluentMvc
 public void SetActionFilterRegistry(IActionFilterRegistry registry)
 {
     actionFilterRegistry = registry;
 }
コード例 #41
0
 public void SetActionFilterRegistry(IActionFilterRegistry registry)
 {
     throw new System.NotImplementedException();
 }