public void AddIgnoredAssembly()
        {
            ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance;

            Assert.That(filter.ShouldConsiderAssembly(typeof(ApplicationAssemblyLoaderFilter).Assembly.GetName()), Is.True);
            filter.AddIgnoredAssembly(typeof(ApplicationAssemblyLoaderFilter).Assembly.GetName().Name);
            Assert.That(filter.ShouldConsiderAssembly(typeof(ApplicationAssemblyLoaderFilter).Assembly.GetName()), Is.False);
        }
Ejemplo n.º 2
0
        protected virtual void InitializeConfiguration(string assemblyDirectory)
        {
            ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance;

            // TODO: Duplicates logic from AssemblyFinder? The DLL searching part below can probably be removed.
            List <Assembly> assemblies = new List <Assembly>();
            DirectoryInfo   dir        = new DirectoryInfo(assemblyDirectory);

            foreach (FileInfo file in dir.GetFiles("*.dll"))
            {
                Assembly asm = Assembly.LoadFile(file.FullName);
                if (filter.ShouldConsiderAssembly(asm.GetName()) && filter.ShouldIncludeAssembly(asm))
                {
                    assemblies.Add(asm);
                }
            }
            DomainObjectsConfiguration.SetCurrent(
                new FakeDomainObjectsConfiguration(DomainObjectsConfiguration.Current.MappingLoader, GetPersistenceConfiguration(), new QueryConfiguration()));

            var rootAssemblyFinder = new FixedRootAssemblyFinder(assemblies.Select(a => new RootAssembly(a, false)).ToArray());

            var assemblyLoader = new FilteringAssemblyLoader(filter);
            ITypeDiscoveryService typeDiscoveryService =
                new AssemblyFinderTypeDiscoveryService(new AssemblyFinder(rootAssemblyFinder, assemblyLoader));

            var mappingReflector       = new MappingReflector(typeDiscoveryService);
            var persistenceModelLoader =
                new PersistenceModelLoader(new StorageProviderDefinitionFinder(DomainObjectsConfiguration.Current.Storage));
            var mappingConfiguration = new MappingConfiguration(mappingReflector, persistenceModelLoader);

            MappingConfiguration.SetCurrent(mappingConfiguration);
        }
        public void ApplicationAssemblyConsidering()
        {
            ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance;

            Assert.That(filter.ShouldConsiderAssembly(typeof(AttributeAssemblyLoaderFilterTest).Assembly.GetName()), Is.True);
            Assert.That(filter.ShouldConsiderAssembly(typeof(TestFixtureAttribute).Assembly.GetName()), Is.True);
            Assert.That(filter.ShouldConsiderAssembly(typeof(ApplicationAssemblyLoaderFilter).Assembly.GetName()), Is.True);

            Assert.That(filter.ShouldConsiderAssembly(typeof(object).Assembly.GetName()), Is.False);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("System")), Is.False);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("Microsoft.Something.Whatever")), Is.False);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("Remotion.Mixins.Generated.Unsigned")), Is.False);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("Remotion.Mixins.Generated.Signed")), Is.False);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("Remotion.Data.DomainObjects.Generated.Signed")), Is.False);
            Assert.That(filter.ShouldConsiderAssembly(new AssemblyName("Remotion.Data.DomainObjects.Generated.Unsigned")), Is.False);
        }