public void RegisterLegacyTypesToNewDefaultServiceLocator()
        {
            var legacyServiceTypes = BocLegacyServiceConfigurationService.GetConfiguration();

            var locator = DefaultServiceLocator.Create();

            foreach (var serviceConfigurationEntry in legacyServiceTypes)
            {
                locator.Register(serviceConfigurationEntry);
            }

            foreach (var legacyServiceType in legacyServiceTypes)
            {
                Assert.That(locator.GetInstance(legacyServiceType.ServiceType), Is.TypeOf(GetSingleServiceImplementationInfo(legacyServiceType).ImplementationType));
            }
        }
        public void GetConfiguration()
        {
            var discoveryService = DefaultServiceConfigurationDiscoveryService.Create();
            var allServiceTypes  = discoveryService.GetDefaultConfiguration(new[] { typeof(IBocList).Assembly })
                                   .Select(e => e.ServiceType).ToList();
            var nonLegacyServices          = new[] { typeof(BocListCssClassDefinition), typeof(IDateTimeFormatter) };
            var expectedLegacyServiceTypes = allServiceTypes
                                             .Except(nonLegacyServices)
                                             .Concat(typeof(BocListQuirksModeCssClassDefinition));

            Assert.That(
                BocLegacyServiceConfigurationService.GetConfiguration().Select(e => e.ServiceType),
                Is.EquivalentTo(expectedLegacyServiceTypes));

            Assert.That(
                BocLegacyServiceConfigurationService.GetConfiguration()
                .Where(e => !nonLegacyServices.Contains(e.ServiceType))
                .Select(e => GetSingleServiceImplementationInfo(e).ImplementationType.Assembly)
                .ToArray(),
                Is.All.EqualTo(typeof(BocLegacyServiceConfigurationService).Assembly));
        }
Пример #3
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            LogManager.Initialize();
            PreferQuirksModeRendering = false;
            bool useClassicBlueTheme = false;

            if (useClassicBlueTheme)
            {
                DefaultServiceLocator defaultServiceLocator = DefaultServiceLocator.Create();
                defaultServiceLocator.Register(typeof(ResourceTheme), typeof(ResourceTheme.ClassicBlue), LifetimeKind.Singleton);
                ServiceLocator.SetLocatorProvider(() => defaultServiceLocator);
            }

            string objectPath = Server.MapPath("~/objects");

            if (!Directory.Exists(objectPath))
            {
                Directory.CreateDirectory(objectPath);
            }

            XmlReflectionBusinessObjectStorageProvider provider = new XmlReflectionBusinessObjectStorageProvider(objectPath);

            XmlReflectionBusinessObjectStorageProvider.SetCurrent(provider);
            BusinessObjectProvider.GetProvider <BindableObjectWithIdentityProviderAttribute>().AddService(typeof(IGetObjectService), provider);
            BusinessObjectProvider.GetProvider <BindableObjectWithIdentityProviderAttribute>()
            .AddService(typeof(ISearchAvailableObjectsService), new BindableXmlObjectSearchService());
            BusinessObjectProvider.GetProvider <BindableObjectWithIdentityProviderAttribute>()
            .AddService(typeof(IBusinessObjectWebUIService), new ReflectionBusinessObjectWebUIService());

            BusinessObjectProvider.GetProvider <BindableObjectProviderAttribute>().AddService(new ReferenceDataSourceTestDefaultValueService());
            BusinessObjectProvider.GetProvider <BindableObjectProviderAttribute>().AddService(new ReferenceDataSourceTestDeleteObjectService());

            if (PreferQuirksModeRendering)
            {
                DefaultServiceLocator defaultServiceLocator = DefaultServiceLocator.Create();
                foreach (var entry in LegacyServiceConfigurationService.GetConfiguration())
                {
                    defaultServiceLocator.Register(entry);
                }
                foreach (var entry in BocLegacyServiceConfigurationService.GetConfiguration())
                {
                    defaultServiceLocator.Register(entry);
                }

                ServiceLocator.SetLocatorProvider(() => defaultServiceLocator);

                Assertion.IsTrue(SafeServiceLocator.Current.GetInstance <IBocListRenderer>() is BocListQuirksModeRenderer);
                Assertion.IsTrue(SafeServiceLocator.Current.GetInstance <IBocTextValueRenderer>() is BocTextValueQuirksModeRenderer);
            }

            _resourceVirtualPathProvider = new ResourceVirtualPathProvider(
                new[]
            {
                new ResourcePathMapping("Remotion.Web", @"..\..\Web\Core\res"),
                new ResourcePathMapping("Remotion.ObjectBinding.Web", @"..\..\ObjectBinding\Web\res"),
                new ResourcePathMapping("Remotion.Web.Legacy", @"..\..\Web\Legacy\res"),
                new ResourcePathMapping("Remotion.ObjectBinding.Web.Legacy", @"..\..\ObjectBinding\Web.Legacy\res")
            },
                FileExtensionHandlerMapping.Default);
            _resourceVirtualPathProvider.Register();

            //var bundle = new Bundle ("~/bundles/css");
            //foreach (var resourcePathMapping in _resourceVirtualPathProvider.Mappings)
            //  BundleCssFilesRecursively ((ResourceVirtualDirectory) _resourceVirtualPathProvider.GetDirectory(resourcePathMapping.VirtualPath), bundle);

            //BundleTable.Bundles.Add (bundle);
        }