/// <summary>
		/// Services the specified service provider.
		/// </summary>
		/// <param name="serviceProvider">The service provider.</param>
		public void Service(IServiceProvider serviceProvider)
		{
			ILoggerFactory loggerFactory = (ILoggerFactory) serviceProvider.GetService(typeof(ILoggerFactory));
			
			if (loggerFactory != null)
			{
				logger = loggerFactory.Create(typeof(DefaultControllerDescriptorProvider));
			}

			helperDescriptorProvider = (IHelperDescriptorProvider) 
				serviceProvider.GetService(typeof(IHelperDescriptorProvider));

			filterDescriptorProvider = (IFilterDescriptorProvider)
				serviceProvider.GetService(typeof(IFilterDescriptorProvider));

			layoutDescriptorProvider = (ILayoutDescriptorProvider)
				serviceProvider.GetService(typeof(ILayoutDescriptorProvider));

			rescueDescriptorProvider = (IRescueDescriptorProvider)
				serviceProvider.GetService(typeof(IRescueDescriptorProvider));
		
			resourceDescriptorProvider = (IResourceDescriptorProvider)
				serviceProvider.GetService(typeof(IResourceDescriptorProvider));
			
			transformFilterDescriptorProvider = (ITransformFilterDescriptorProvider)
				serviceProvider.GetService(typeof(ITransformFilterDescriptorProvider));
		}
        public void DescriptorIsCreatedForControllerAndAction()
        {
            helperDescProviderMock                = mockRepository.DynamicMock <IHelperDescriptorProvider>();
            filterDescProviderMock                = mockRepository.DynamicMock <IFilterDescriptorProvider>();
            layoutDescProviderMock                = mockRepository.DynamicMock <ILayoutDescriptorProvider>();
            rescueDescProviderMock                = mockRepository.DynamicMock <IRescueDescriptorProvider>();
            resourceProviderMock                  = mockRepository.DynamicMock <IResourceDescriptorProvider>();
            transformDescProviderMock             = mockRepository.DynamicMock <ITransformFilterDescriptorProvider>();
            returnTypeDescProviderMock            = mockRepository.DynamicMock <IReturnBinderDescriptorProvider>();
            dynamicActionProviderDescProviderMock = mockRepository.DynamicMock <IDynamicActionProviderDescriptorProvider>();

            provider = new DefaultControllerDescriptorProvider(helperDescProviderMock,
                                                               filterDescProviderMock,
                                                               layoutDescProviderMock,
                                                               rescueDescProviderMock,
                                                               resourceProviderMock,
                                                               transformDescProviderMock, returnTypeDescProviderMock,
                                                               dynamicActionProviderDescProviderMock);

            var controllerType = typeof(SingleActionController);
            var actionMethod   = controllerType.GetMethod("Action1");

            using (mockRepository.Record())
            {
                // Controller level
                Expect.Call(helperDescProviderMock.CollectHelpers(controllerType)).Return(new HelperDescriptor[0]);
                Expect.Call(resourceProviderMock.CollectResources(controllerType)).Return(new ResourceDescriptor[0]);
                Expect.Call(filterDescProviderMock.CollectFilters(controllerType)).Return(new FilterDescriptor[0]);
                Expect.Call(layoutDescProviderMock.CollectLayout(controllerType)).Return(null);
                Expect.Call(rescueDescProviderMock.CollectRescues(controllerType)).Return(new RescueDescriptor[0]);

                // Action level
                Expect.Call(resourceProviderMock.CollectResources(actionMethod)).Return(new ResourceDescriptor[0]);
                Expect.Call(rescueDescProviderMock.CollectRescues(actionMethod)).Return(new RescueDescriptor[0]);
                Expect.Call(layoutDescProviderMock.CollectLayout(actionMethod)).Return(null);
                Expect.Call(transformDescProviderMock.CollectFilters(actionMethod)).Return(new TransformFilterDescriptor[0]);
                Expect.Call(returnTypeDescProviderMock.Collect(actionMethod)).Return(null);
                Expect.Call(dynamicActionProviderDescProviderMock.CollectProviders(controllerType)).Return(
                    new DynamicActionProviderDescriptor[0]);
            }

            using (mockRepository.Playback())
            {
                var metaDesc = provider.BuildDescriptor(controllerType);
                Assert.IsNotNull(metaDesc);
                var actionMetaDesc = metaDesc.GetAction(actionMethod);
                Assert.IsNotNull(actionMetaDesc);
                Assert.IsNull(actionMetaDesc.AccessibleThrough);
            }
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="DefaultControllerDescriptorProvider"/> class.
		/// </summary>
		/// <param name="helperDescriptorProvider">The helper descriptor provider.</param>
		/// <param name="filterDescriptorProvider">The filter descriptor provider.</param>
		/// <param name="layoutDescriptorProvider">The layout descriptor provider.</param>
		/// <param name="rescueDescriptorProvider">The rescue descriptor provider.</param>
		/// <param name="resourceDescriptorProvider">The resource descriptor provider.</param>
		/// <param name="transformFilterDescriptorProvider">The transform filter descriptor provider.</param>
		/// <param name="returnBinderDescriptorProvider">The return binder descriptor provider.</param>
		/// <param name="dynamicActionProviderDescriptorProvider">The dynamic action provider descriptor provider.</param>
		public DefaultControllerDescriptorProvider(IHelperDescriptorProvider helperDescriptorProvider, 
													IFilterDescriptorProvider filterDescriptorProvider, 
													ILayoutDescriptorProvider layoutDescriptorProvider, 
													IRescueDescriptorProvider rescueDescriptorProvider, 
													IResourceDescriptorProvider resourceDescriptorProvider, 
													ITransformFilterDescriptorProvider transformFilterDescriptorProvider, 
													IReturnBinderDescriptorProvider returnBinderDescriptorProvider, 
													IDynamicActionProviderDescriptorProvider dynamicActionProviderDescriptorProvider)
		{
			this.helperDescriptorProvider = helperDescriptorProvider;
			this.filterDescriptorProvider = filterDescriptorProvider;
			this.layoutDescriptorProvider = layoutDescriptorProvider;
			this.rescueDescriptorProvider = rescueDescriptorProvider;
			this.resourceDescriptorProvider = resourceDescriptorProvider;
			this.transformFilterDescriptorProvider = transformFilterDescriptorProvider;
			this.returnBinderDescriptorProvider = returnBinderDescriptorProvider;
			this.dynamicActionProviderDescriptorProvider = dynamicActionProviderDescriptorProvider;
		}
        /// <summary>
        /// Services the specified service provider.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        public void Service(IMonoRailServices serviceProvider)
        {
            var loggerFactory = (ILoggerFactory)serviceProvider.GetService(typeof(ILoggerFactory));

            if (loggerFactory != null)
            {
                logger = loggerFactory.Create(typeof(DefaultControllerDescriptorProvider));
            }

            helperDescriptorProvider                = serviceProvider.GetService <IHelperDescriptorProvider>();
            filterDescriptorProvider                = serviceProvider.GetService <IFilterDescriptorProvider>();
            layoutDescriptorProvider                = serviceProvider.GetService <ILayoutDescriptorProvider>();
            rescueDescriptorProvider                = serviceProvider.GetService <IRescueDescriptorProvider>();
            resourceDescriptorProvider              = serviceProvider.GetService <IResourceDescriptorProvider>();
            transformFilterDescriptorProvider       = serviceProvider.GetService <ITransformFilterDescriptorProvider>();
            returnBinderDescriptorProvider          = serviceProvider.GetService <IReturnBinderDescriptorProvider>();
            dynamicActionProviderDescriptorProvider = serviceProvider.GetService <IDynamicActionProviderDescriptorProvider>();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultControllerDescriptorProvider"/> class.
 /// </summary>
 /// <param name="helperDescriptorProvider">The helper descriptor provider.</param>
 /// <param name="filterDescriptorProvider">The filter descriptor provider.</param>
 /// <param name="layoutDescriptorProvider">The layout descriptor provider.</param>
 /// <param name="rescueDescriptorProvider">The rescue descriptor provider.</param>
 /// <param name="resourceDescriptorProvider">The resource descriptor provider.</param>
 /// <param name="transformFilterDescriptorProvider">The transform filter descriptor provider.</param>
 /// <param name="returnBinderDescriptorProvider">The return binder descriptor provider.</param>
 /// <param name="dynamicActionProviderDescriptorProvider">The dynamic action provider descriptor provider.</param>
 public DefaultControllerDescriptorProvider(IHelperDescriptorProvider helperDescriptorProvider,
                                            IFilterDescriptorProvider filterDescriptorProvider,
                                            ILayoutDescriptorProvider layoutDescriptorProvider,
                                            IRescueDescriptorProvider rescueDescriptorProvider,
                                            IResourceDescriptorProvider resourceDescriptorProvider,
                                            ITransformFilterDescriptorProvider transformFilterDescriptorProvider,
                                            IReturnBinderDescriptorProvider returnBinderDescriptorProvider,
                                            IDynamicActionProviderDescriptorProvider dynamicActionProviderDescriptorProvider)
 {
     this.helperDescriptorProvider                = helperDescriptorProvider;
     this.filterDescriptorProvider                = filterDescriptorProvider;
     this.layoutDescriptorProvider                = layoutDescriptorProvider;
     this.rescueDescriptorProvider                = rescueDescriptorProvider;
     this.resourceDescriptorProvider              = resourceDescriptorProvider;
     this.transformFilterDescriptorProvider       = transformFilterDescriptorProvider;
     this.returnBinderDescriptorProvider          = returnBinderDescriptorProvider;
     this.dynamicActionProviderDescriptorProvider = dynamicActionProviderDescriptorProvider;
 }
		public void DescriptorIsCreatedForControllerAndAction()
		{
			helperDescProviderMock = mockRepository.DynamicMock<IHelperDescriptorProvider>();
			filterDescProviderMock = mockRepository.DynamicMock<IFilterDescriptorProvider>();
			layoutDescProviderMock = mockRepository.DynamicMock<ILayoutDescriptorProvider>();
			rescueDescProviderMock = mockRepository.DynamicMock<IRescueDescriptorProvider>();
			resourceProviderMock = mockRepository.DynamicMock<IResourceDescriptorProvider>();
			transformDescProviderMock = mockRepository.DynamicMock<ITransformFilterDescriptorProvider>();
			returnTypeDescProviderMock = mockRepository.DynamicMock<IReturnBinderDescriptorProvider>();
			dynamicActionProviderDescProviderMock = mockRepository.DynamicMock<IDynamicActionProviderDescriptorProvider>();

			provider = new DefaultControllerDescriptorProvider(helperDescProviderMock,
															   filterDescProviderMock,
															   layoutDescProviderMock,
															   rescueDescProviderMock,
															   resourceProviderMock,
															   transformDescProviderMock, returnTypeDescProviderMock,
															   dynamicActionProviderDescProviderMock);

			Type controllerType = typeof(SingleActionController);
			MethodInfo actionMethod = controllerType.GetMethod("Action1");

			using(mockRepository.Record())
			{
				// Controller level
				Expect.Call(helperDescProviderMock.CollectHelpers(controllerType)).Return(new HelperDescriptor[0]);
				Expect.Call(resourceProviderMock.CollectResources(controllerType)).Return(new ResourceDescriptor[0]);
				Expect.Call(filterDescProviderMock.CollectFilters(controllerType)).Return(new FilterDescriptor[0]);
				Expect.Call(layoutDescProviderMock.CollectLayout(controllerType)).Return(null);
				Expect.Call(rescueDescProviderMock.CollectRescues(controllerType)).Return(new RescueDescriptor[0]);
			
				// Action level
				Expect.Call(resourceProviderMock.CollectResources(actionMethod)).Return(new ResourceDescriptor[0]);
				Expect.Call(rescueDescProviderMock.CollectRescues(actionMethod)).Return(new RescueDescriptor[0]);
				Expect.Call(layoutDescProviderMock.CollectLayout(actionMethod)).Return(null);
				Expect.Call(transformDescProviderMock.CollectFilters(actionMethod)).Return(new TransformFilterDescriptor[0]);
				Expect.Call(returnTypeDescProviderMock.Collect(actionMethod)).Return(null);
				Expect.Call(dynamicActionProviderDescProviderMock.CollectProviders(controllerType)).Return(
					new DynamicActionProviderDescriptor[0]);
			}

			using(mockRepository.Playback())
			{
				ControllerMetaDescriptor metaDesc = provider.BuildDescriptor(controllerType);
				Assert.IsNotNull(metaDesc);
				ActionMetaDescriptor actionMetaDesc = metaDesc.GetAction(actionMethod);
				Assert.IsNotNull(actionMetaDesc);
				Assert.IsNull(actionMetaDesc.AccessibleThrough);
			}
		}
예제 #7
0
 public HalResourceController(IEnumerable<IContextEnviromentProvider> environmentProviders, IResourceDescriptorProvider resourceDescriptorProvider, IResourceLinkPersistence resourceLinkPersistence)
 {
     _environmentProviders = environmentProviders;
     _resourceDescriptorProvider = resourceDescriptorProvider;
     _resourceLinkPersistence = resourceLinkPersistence;
 }
		/// <summary>
		/// Services the specified service provider.
		/// </summary>
		/// <param name="serviceProvider">The service provider.</param>
		public void Service(IMonoRailServices serviceProvider)
		{
			var loggerFactory = (ILoggerFactory) serviceProvider.GetService(typeof(ILoggerFactory));

			if (loggerFactory != null)
			{
				logger = loggerFactory.Create(typeof(DefaultControllerDescriptorProvider));
			}

			helperDescriptorProvider = serviceProvider.GetService<IHelperDescriptorProvider>();
			filterDescriptorProvider = serviceProvider.GetService<IFilterDescriptorProvider>();
			layoutDescriptorProvider = serviceProvider.GetService<ILayoutDescriptorProvider>();
			rescueDescriptorProvider = serviceProvider.GetService<IRescueDescriptorProvider>();
			resourceDescriptorProvider = serviceProvider.GetService<IResourceDescriptorProvider>();
			transformFilterDescriptorProvider = serviceProvider.GetService<ITransformFilterDescriptorProvider>();
			returnBinderDescriptorProvider = serviceProvider.GetService<IReturnBinderDescriptorProvider>();
			dynamicActionProviderDescriptorProvider = serviceProvider.GetService<IDynamicActionProviderDescriptorProvider>();
		}
예제 #9
0
 public HalController(IResourceDescriptorProvider resourceDescriptorProvider, IHalRuleService halRuleService)
 {
     _resourceDescriptorProvider = resourceDescriptorProvider;
     _halRuleService = halRuleService;
 }
예제 #10
0
 public DefaultUriResolver(IResourceDescriptorProvider resourceProvider)
 {
     _resourceProvider = resourceProvider;
 }