Пример #1
0
        private /*static*/ string getAssemblyName(Assembly assembly, FormatterAssemblyStyle assemblyStyle)
        {
            System.Diagnostics.Debug.Assert(null != assembly, "The 'assembly' argument cannot be null.");

            AssemblyInfo assemblyInfo = new AssemblyInfo(assembly);

            if (assemblyInfo.Name == "mscorlib" || assemblyInfo.Name == "System")
            {
                return(null);
            }

            string assemblyName = assemblyInfo.ToString();

            if (FormatterAssemblyStyle.Simple == assemblyStyle)
            {
                assemblyName = assemblyInfo.Name;
            }
            return(assemblyName);
        }
Пример #2
0
        /// <summary>
        /// Resolves the specified assembly name.
        /// </summary>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <returns>The assembly with the specified name.</returns>
        public Assembly Resolve(string assemblyName)
        {
            if (string.IsNullOrEmpty(assemblyName))
                throw new ArgumentException("string assemblyName should not be null or empty.", "assemblyName");

            AssemblyInfo assemblyInfo = new AssemblyInfo(assemblyName);

            foreach (Assembly loadedAssembly in this.GetLoadedAssemblies())
            {
                AssemblyInfo loadedAssemblyInfo = new AssemblyInfo(loadedAssembly);
                if (assemblyInfo.Equals(loadedAssemblyInfo))
                    return loadedAssembly;
            }

            foreach (AssemblyName referencedAssemblyName in Assembly.GetCallingAssembly().GetReferencedAssemblies())
            {
                AssemblyInfo referencedAssemblyInfo = new AssemblyInfo(referencedAssemblyName);
                if (assemblyInfo.Equals(referencedAssemblyInfo))
                    return Assembly.Load(referencedAssemblyName);
            }

            throw new Exception(string.Format("The assembly '{0}' could not be resolved.", assemblyInfo.ToString()));
        }
Пример #3
0
		private /*static*/ string getAssemblyName(Assembly assembly, FormatterAssemblyStyle assemblyStyle)
		{
			System.Diagnostics.Debug.Assert(null != assembly, "The 'assembly' argument cannot be null.");

			AssemblyInfo assemblyInfo = new AssemblyInfo(assembly);
			if (assemblyInfo.Name == "mscorlib" || assemblyInfo.Name == "System")
				return null;

			string assemblyName = assemblyInfo.ToString();
			if (FormatterAssemblyStyle.Simple == assemblyStyle)
				assemblyName = assemblyInfo.Name;
			return assemblyName;
		}
Пример #4
0
        /// <summary>
        /// Resolves the specified assembly name.
        /// </summary>
        /// <param name="assemblyName">Name of the assembly.</param>
        /// <returns>The assembly with the specified name.</returns>
        public Assembly Resolve(string assemblyName)
        {
            if (string.IsNullOrEmpty(assemblyName))
            {
                throw new ArgumentException("string assemblyName should not be null or empty.", "assemblyName");
            }

            AssemblyInfo assemblyInfo = new AssemblyInfo(assemblyName);

            foreach (Assembly loadedAssembly in this.GetLoadedAssemblies())
            {
                AssemblyInfo loadedAssemblyInfo = new AssemblyInfo(loadedAssembly);
                if (assemblyInfo.Equals(loadedAssemblyInfo))
                {
                    return(loadedAssembly);
                }
            }

            foreach (AssemblyName referencedAssemblyName in Assembly.GetCallingAssembly().GetReferencedAssemblies())
            {
                AssemblyInfo referencedAssemblyInfo = new AssemblyInfo(referencedAssemblyName);
                if (assemblyInfo.Equals(referencedAssemblyInfo))
                {
                    return(Assembly.Load(referencedAssemblyName));
                }
            }

            throw new Exception(string.Format("The assembly '{0}' could not be resolved.", assemblyInfo.ToString()));
        }