public void AddAssembly() { var binder = new AssemblyBinder(); binder.Assemblies.Add(this.GetType().Assembly); Assert.AreEqual(1, binder.Assemblies.Count); Assert.IsTrue(binder.Assemblies.Contains(this.GetType().Assembly)); }
public void BindToTypeWhereAssemblyDoesNotExist() { var binder = new AssemblyBinder(); binder.Assemblies.Add(this.GetType().Assembly); Assert.That(binder.BindToType(typeof(Rock).Assembly.FullName !, this.GetType().FullName !), Is.Null); }
public void BindToType() { var binder = new AssemblyBinder(); binder.Assemblies.Add(this.GetType().Assembly); Assert.That(binder.BindToType(this.GetType().Assembly.FullName !, this.GetType().FullName !), Is.EqualTo(this.GetType())); }
public void AddAssembly() { var binder = new AssemblyBinder(); binder.Assemblies.Add(this.GetType().Assembly); Assert.That(binder.Assemblies.Count, Is.EqualTo(1)); Assert.That(binder.Assemblies.Contains(this.GetType().Assembly), Is.True); }
/// <summary> /// Initializes DI container and binds all dependencies /// </summary> /// <returns>The DI container instance</returns> public static Container InitializeDI() { var container = SimpleInjectorContainer.Initialize(); CoreBootstrapper.BindDependencies(); RedisBootstrapper.BindDependencies(); ApiMockBootstrapper.BindDependencies(); AssemblyBinder.BindAssemby(typeof(AppBootstrapper).Assembly); container.Container.Register <IRedisConfiguration>(RedisConfig.Read, Lifestyle.Singleton); return(container.Container); }
/// <summary> /// Returns a *freshly allocated* array of loaded Assemblies. /// </summary> internal static Assembly[] GetLoadedAssemblies() { // Important: The result of this method is the return value of the AppDomain.GetAssemblies() api so // so it must return a freshly allocated array on each call. AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; IList <AssemblyBindResult> bindResults = binder.GetLoadedAssemblies(); Assembly[] results = new Assembly[bindResults.Count]; for (int i = 0; i < bindResults.Count; i++) { Assembly assembly = GetRuntimeAssembly(bindResults[i]); results[i] = assembly; } return(results); }
/// <summary> /// Returns non-null or throws. /// </summary> internal static RuntimeAssembly GetRuntimeAssemblyFromPath(string assemblyPath) { AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; if (!binder.Bind(assemblyPath, out AssemblyBindResult bindResult, out Exception exception)) { if (exception != null) { throw exception; } else { throw new BadImageFormatException(); } } RuntimeAssembly result = GetRuntimeAssembly(bindResult, assemblyPath); return(result); }
/// <summary> /// Returns non-null or throws. /// </summary> internal static RuntimeAssembly GetRuntimeAssemblyFromByteArray(byte[] rawAssembly, byte[] pdbSymbolStore) { AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; if (!binder.Bind(rawAssembly, pdbSymbolStore, out AssemblyBindResult bindResult, out Exception exception)) { if (exception != null) { throw exception; } else { throw new BadImageFormatException(); } } RuntimeAssembly result = GetRuntimeAssembly(bindResult); return(result); }
/// <summary> /// Returns non-null or throws. /// </summary> internal static RuntimeAssembly GetRuntimeAssemblyFromByteArray(byte[] rawAssembly, byte[] pdbSymbolStore) { AssemblyBinder binder = ReflectionCoreExecution.ExecutionDomain.ReflectionDomainSetup.AssemblyBinder; AssemblyBindResult bindResult; Exception exception; if (!binder.Bind(rawAssembly, pdbSymbolStore, out bindResult, out exception)) { if (exception != null) { throw exception; } else { throw new BadImageFormatException(); } } RuntimeAssembly result = null; GetNativeFormatRuntimeAssembly(bindResult, ref result); if (result != null) { return(result); } GetEcmaRuntimeAssembly(bindResult, ref result); if (result != null) { return(result); } else { throw new PlatformNotSupportedException(); } }
// Binds all services to default implementations public static void BindDependencies() => AssemblyBinder.BindAssemby(typeof(CoreBootstrapper).Assembly);
public void Create() { var binder = new AssemblyBinder(); Assert.AreEqual(0, binder.Assemblies.Count); }
public void BindToTypeWhereAssemblyDoesNotExist() { var binder = new AssemblyBinder(); binder.Assemblies.Add(this.GetType().Assembly); Assert.IsNull(binder.BindToType(typeof(Rock).Assembly.FullName, this.GetType().FullName)); }
public void BindToType() { var binder = new AssemblyBinder(); binder.Assemblies.Add(this.GetType().Assembly); Assert.AreEqual(this.GetType(), binder.BindToType(this.GetType().Assembly.FullName, this.GetType().FullName)); }
public void Create() { var binder = new AssemblyBinder(); Assert.That(binder.Assemblies.Count, Is.EqualTo(0)); }