private ITypeDiscoveryService CreateServiceWithAssemblyFinder(IRootAssemblyFinder customRootAssemblyFinder)
        {
            var filteringAssemblyLoader = CreateApplicationAssemblyLoader();
            var assemblyFinder          = new CachingAssemblyFinderDecorator(new AssemblyFinder(customRootAssemblyFinder, filteringAssemblyLoader));

            return(new AssemblyFinderTypeDiscoveryService(assemblyFinder));
        }
Exemplo n.º 2
0
        public static void Initialize()
        {
            ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>();

            providers.Add(new RdbmsProviderDefinition("PerformanceTestDomain", new SqlStorageObjectFactory(), ConnectionString));
            StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["PerformanceTestDomain"]);

            DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration));


            var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(StandardConfiguration).Assembly, true));
            var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
            var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);
            MappingConfiguration  mappingConfiguration = new MappingConfiguration(
                new MappingReflector(
                    typeDiscoveryService,
                    new ClassIDProvider(),
                    new ReflectionBasedMemberInformationNameResolver(),
                    new PropertyMetadataReflector(),
                    new DomainModelConstraintProvider(),
                    MappingReflector.CreateDomainObjectCreator()),
                new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage)));

            MappingConfiguration.SetCurrent(mappingConfiguration);
        }
        private ITypeDiscoveryService GetTypeDiscoveryService(string testDomainNamespace, params Assembly[] rootAssemblies)
        {
            var rootAssemblyFinder = new FixedRootAssemblyFinder(rootAssemblies.Select(asm => new RootAssembly(asm, true)).ToArray());
            var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
            var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

            return(FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist(typeDiscoveryService, testDomainNamespace));
        }
Exemplo n.º 4
0
        public static Mixer Create(string assemblyName, string assemblyOutputDirectory, int degreeOfParallelism)
        {
            var builderFactory = new MixerPipelineFactory(assemblyName, degreeOfParallelism);

            // Use a custom TypeDiscoveryService with the LoadAllAssemblyLoaderFilter so that mixed types within system assemblies are also considered.
            var assemblyLoader       = new FilteringAssemblyLoader(new LoadAllAssemblyLoaderFilter());
            var rootAssemblyFinder   = SearchPathRootAssemblyFinder.CreateForCurrentAppDomain(false, assemblyLoader);
            var assemblyFinder       = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            var typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

            var finder = new MixedTypeFinder(typeDiscoveryService);

            return(new Mixer(finder, builderFactory, assemblyOutputDirectory));
        }
        public static ITypeDiscoveryService GetTypeDiscoveryService()
        {
            var mappingRootNamespace = typeof(TestMappingConfiguration).Namespace;
            var testMappingNamespace = mappingRootNamespace + ".TestDomain.Integration";

            var rootAssemlbies       = new[] { new RootAssembly(typeof(TestMappingConfiguration).Assembly, true) };
            var rootAssemblyFinder   = new FixedRootAssemblyFinder(rootAssemlbies);
            var assemblyLoader       = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
            var assemblyFinder       = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            var typeDiscoveryService = (ITypeDiscoveryService) new AssemblyFinderTypeDiscoveryService(assemblyFinder);

            typeDiscoveryService = FilteringTypeDiscoveryService.CreateFromNamespaceWhitelist(typeDiscoveryService, testMappingNamespace);

            return(typeDiscoveryService);
        }
Exemplo n.º 6
0
        public int Run()
        {
            try
            {
                ServiceLocator.SetLocatorProvider(() => null);

                var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
                var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(BaseSecurityManagerObject).Assembly, true));
                var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));

                ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);
                MappingConfiguration.SetCurrent(
                    new MappingConfiguration(
                        new MappingReflector(
                            typeDiscoveryService,
                            new ClassIDProvider(),
                            new ReflectionBasedMemberInformationNameResolver(),
                            new PropertyMetadataReflector(),
                            new DomainModelConstraintProvider(),
                            MappingReflector.CreateDomainObjectCreator()),
                        new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))));

                ClientTransaction transaction = ClientTransaction.CreateRootTransaction();

                if (_arguments.ImportMetadata)
                {
                    ImportMetadata(transaction);
                }

                transaction.Commit();

                if (_arguments.ImportLocalization)
                {
                    ImportLocalization(transaction);
                }

                transaction.Commit();

                return(0);
            }
            catch (Exception e)
            {
                HandleException(e);
                return(1);
            }
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            try
            {
                var serviceLocator = DefaultServiceLocator.Create();
                serviceLocator.RegisterSingle <ISecurityProvider> (() => new NullSecurityProvider());
                serviceLocator.RegisterSingle <IPrincipalProvider> (() => new NullPrincipalProvider());
                ServiceLocator.SetLocatorProvider(() => serviceLocator);

                var providers = new ProviderCollection <StorageProviderDefinition>();
                providers.Add(new RdbmsProviderDefinition("SecurityManager", new SecurityManagerSqlStorageObjectFactory(), TestDomainConnectionString));
                var storageConfiguration = new StorageConfiguration(providers, providers["SecurityManager"]);
                storageConfiguration.StorageGroups.Add(new StorageGroupElement(new SecurityManagerStorageGroupAttribute(), "SecurityManager"));

                DomainObjectsConfiguration.SetCurrent(new FakeDomainObjectsConfiguration(storage: storageConfiguration));

                var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(BaseSecurityManagerObject).Assembly, true));
                var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
                var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
                ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

                MappingConfiguration.SetCurrent(
                    new MappingConfiguration(
                        new MappingReflector(
                            typeDiscoveryService,
                            new ClassIDProvider(),
                            new ReflectionBasedMemberInformationNameResolver(),
                            new PropertyMetadataReflector(),
                            new DomainModelConstraintProvider(),
                            MappingReflector.CreateDomainObjectCreator()),
                        new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))));

                SqlConnection.ClearAllPools();

                DatabaseAgent masterAgent = new DatabaseAgent(MasterConnectionString);
                masterAgent.ExecuteBatchFile("SecurityManagerCreateDB.sql", false, DatabaseConfiguration.GetReplacementDictionary());
                DatabaseAgent databaseAgent = new DatabaseAgent(TestDomainConnectionString);
                databaseAgent.ExecuteBatchFile("SecurityManagerSetupDB.sql", true);
                databaseAgent.ExecuteBatchFile("SecurityManagerSetupConstraints.sql", true);
                databaseAgent.ExecuteBatchFile("SecurityManagerSetupDBSpecialTables.sql", true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public static ITypeDiscoveryService GetTypeDiscoveryService(params Assembly[] rootAssemblies)
        {
            var rootAssemblyFinder = new FixedRootAssemblyFinder(rootAssemblies.Select(asm => new RootAssembly(asm, true)).ToArray());
            var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
            var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
            ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

            return(FilteringTypeDiscoveryService.CreateFromNamespaceBlacklist(
                       typeDiscoveryService,
                       "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Errors",
                       "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Integration",
                       "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.RelationReflector",
                       "Remotion.Data.DomainObjects.UnitTests.Mapping.TestDomain.Validation",
                       "Remotion.Data.DomainObjects.UnitTests.Mapping.MappingReflectionIntegrationTests",
                       "Remotion.Data.DomainObjects.UnitTests.Security.TestDomain",
                       "Remotion.Data.DomainObjects.UnitTests.Persistence.Rdbms.SchemaGenerationTestDomain"
                       ));
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            try
            {
                ProviderCollection <StorageProviderDefinition> providers = new ProviderCollection <StorageProviderDefinition>();
                providers.Add(new RdbmsProviderDefinition("Development.Data.DomainObjects", new SqlStorageObjectFactory(), "ConnectionString"));
                StorageConfiguration storageConfiguration = new StorageConfiguration(providers, providers["Development.Data.DomainObjects"]);

                DomainObjectsConfiguration.SetCurrent(
                    new FakeDomainObjectsConfiguration(
                        new MappingLoaderConfiguration(),
                        storageConfiguration,
                        new QueryConfiguration()));

                var rootAssemblyFinder = new FixedRootAssemblyFinder(new RootAssembly(typeof(TestDomainObject).Assembly, true));
                var assemblyLoader     = new FilteringAssemblyLoader(ApplicationAssemblyLoaderFilter.Instance);
                var assemblyFinder     = new CachingAssemblyFinderDecorator(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));
                ITypeDiscoveryService typeDiscoveryService = new AssemblyFinderTypeDiscoveryService(assemblyFinder);

                MappingConfiguration.SetCurrent(
                    new MappingConfiguration(
                        new MappingReflector(
                            typeDiscoveryService,
                            new ClassIDProvider(),
                            new ReflectionBasedMemberInformationNameResolver(),
                            new PropertyMetadataReflector(),
                            new DomainModelConstraintProvider(),
                            new ThrowingDomainObjectCreator()),
                        new PersistenceModelLoader(new StorageGroupBasedStorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage))));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 10
0
 public void SetUp()
 {
     _innerFinder = MockRepository.GenerateStrictMock <IAssemblyFinder>();
     _decorator   = new CachingAssemblyFinderDecorator(_innerFinder);
 }