コード例 #1
0
        public static IEnumerable<SitecoreService> SitecoreService()
        {
            var typeProvider = GetServicesControllerScanner();

            var nameGenerator = new NamespaceQualifiedUniqueNameGenerator(DefaultHttpControllerSelector.ControllerSuffix);

            IServicesConfiguration servicesConfiguration = new ServicesSettingsConfigurationProvider();

            var internalService = new SitecoreServices(
                                            typeProvider, 
                                            nameGenerator, 
                                            ResolveMetaDataBuilder(), 
                                            servicesConfiguration);

            return new CachingSitecoreServices(internalService, new WebCacheAdapter()).Collection;
        }
コード例 #2
0
        public SitecoreServicesBehaviour()
        {
            _typeProvider = new Mock<ITypeProvider>();
            _nameGenerator = new Mock<IControllerNameGenerator>();
            _metadataBuilder = new Mock<IMetaDataBuilder>();
            
            var servicesConfiguration = new Mock<IServicesConfiguration>();

            _sut = new SitecoreServices(
                            _typeProvider.Object, 
                            _nameGenerator.Object, 
                            _metadataBuilder.Object, 
                            servicesConfiguration.Object);

            _typeProvider
                .SetupGet(x => x.Types)
                .Returns(new[] { typeof(TestController), typeof(TestService) }.AsQueryable);

            _nameGenerator
                .Setup(x => x.GetName((It.IsAny<Type>())))
                .Returns("foo.bar");

            servicesConfiguration.SetupGet(x => x.Configuration)
                .Returns(new ServicesSettingsConfiguration
                {
                    Services =
                        new ServicesSettingsConfiguration.ServiceConfiguration()
                        {
                            Routes =
                                new ServicesSettingsConfiguration.ServiceConfiguration.RouteConfiguration()
                                {
                                    RouteBase = "/baseurl/"
                                }
                        }
                });
        }
コード例 #3
0
        public SitecoreServicesBehaviour()
        {
            _typeProvider    = new Mock <ITypeProvider>();
            _nameGenerator   = new Mock <IControllerNameGenerator>();
            _metadataBuilder = new Mock <IMetaDataBuilder>();

            var servicesConfiguration = new Mock <IServicesConfiguration>();

            _sut = new SitecoreServices(
                _typeProvider.Object,
                _nameGenerator.Object,
                _metadataBuilder.Object,
                servicesConfiguration.Object);

            _typeProvider
            .SetupGet(x => x.Types)
            .Returns(new[] { typeof(TestController), typeof(TestService) }.AsQueryable);

            _nameGenerator
            .Setup(x => x.GetName((It.IsAny <Type>())))
            .Returns("foo.bar");

            servicesConfiguration.SetupGet(x => x.Configuration)
            .Returns(new ServicesSettingsConfiguration
            {
                Services =
                    new ServicesSettingsConfiguration.ServiceConfiguration()
                {
                    Routes =
                        new ServicesSettingsConfiguration.ServiceConfiguration.RouteConfiguration()
                    {
                        RouteBase = "/baseurl/"
                    }
                }
            });
        }