Beispiel #1
0
        /// <summary>
        /// Evaluates Type of className specified within specific assembly
        /// </summary>
        /// <param name="assemblyName">assembly name with complete namespace</param>
        /// <param name="className">class name with complete namespace</param>
        /// <returns>class Type if exists in assembly else null</returns>
        public static Type GetSpecificAssemblyType(string assemblyName, string className)
        {
            if (String.IsNullOrEmpty(className) || String.IsNullOrEmpty(assemblyName))
            {
                throw new ArgumentNullException();
            }
            Type type = null;
            StreamResourceInfo info     = Application.GetResourceStream(new Uri(assemblyName, UriKind.Relative));
            Assembly           assembly = new AssemblyPart().Load(info.Stream);

            type = assembly.GetType(className);
            return(type);
        }
Beispiel #2
0
        public void LoadNewAssemblyPartFromMemoryStream()
        {
            var assembly = new AssemblyPart().Load(GetLibraryStream());

            Assert.IsNotNull(assembly);

            var type = assembly.GetType("Foo.Bar");

            Assert.IsNotNull(type);

            // a second time ?
            var a2 = new AssemblyPart().Load(GetLibraryStream());

            Assert.IsTrue(Object.ReferenceEquals(assembly, a2), "twice");
        }