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 ApplicationAssemblyInclusion_DependsOnAttribute() { string compiledAssemblyPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NonApplicationMarkedAssembly.dll"); try { AppDomainRunner.Run( delegate(object[] args) { var path = (string)args[0]; ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance; Assert.That(filter.ShouldIncludeAssembly(typeof(AttributeAssemblyLoaderFilterTest).Assembly), Is.True); Assert.That(filter.ShouldIncludeAssembly(typeof(TestFixtureAttribute).Assembly), Is.True); Assert.That(filter.ShouldIncludeAssembly(typeof(ApplicationAssemblyLoaderFilter).Assembly), Is.True); Assert.That(filter.ShouldIncludeAssembly(typeof(object).Assembly), Is.True); Assert.That(filter.ShouldIncludeAssembly(typeof(Uri).Assembly), Is.True); var assemblyCompiler = new AssemblyCompiler(@"Reflection\TypeDiscovery\TestAssemblies\NonApplicationMarkedAssembly", path, typeof(NonApplicationAssemblyAttribute).Assembly.Location); assemblyCompiler.Compile(); Assert.That(filter.ShouldIncludeAssembly(assemblyCompiler.CompiledAssembly), Is.False); }, compiledAssemblyPath); } finally { if (File.Exists(compiledAssemblyPath)) { FileUtility.DeleteAndWaitForCompletion(compiledAssemblyPath); } } }
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); }
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); }
public void ApplicationAssemblyMatchExpression() { ApplicationAssemblyLoaderFilter filter = ApplicationAssemblyLoaderFilter.Instance; Assert.That(filter.SystemAssemblyMatchExpression, Is.EqualTo(@"^((mscorlib)|(System)|(System\..*)|(Microsoft\..*)|(Remotion\..*\.Generated\..*)|(TypePipe_.*Generated.*))$")); }