Ejemplo n.º 1
0
		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));
		}
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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()));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <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);
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
        /// <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();
            }
        }
Ejemplo n.º 10
0
 // Binds all services to default implementations
 public static void BindDependencies()
 => AssemblyBinder.BindAssemby(typeof(CoreBootstrapper).Assembly);
Ejemplo n.º 11
0
		public void Create()
		{
			var binder = new AssemblyBinder();
			Assert.AreEqual(0, binder.Assemblies.Count);
		}
Ejemplo n.º 12
0
		public void BindToTypeWhereAssemblyDoesNotExist()
		{
			var binder = new AssemblyBinder();
			binder.Assemblies.Add(this.GetType().Assembly);
			Assert.IsNull(binder.BindToType(typeof(Rock).Assembly.FullName, this.GetType().FullName));
		}
Ejemplo n.º 13
0
		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));
		}
Ejemplo n.º 14
0
        public void Create()
        {
            var binder = new AssemblyBinder();

            Assert.That(binder.Assemblies.Count, Is.EqualTo(0));
        }