Ejemplo n.º 1
0
		/// <summary>
		/// To modify the build name to <see cref="CodeReference"/>.
		/// </summary>
		/// <param name="referenceName">The build name.</param>
		/// <param name="assemblies">Previously loaded builds.</param>
		/// <returns><see cref="CodeReference"/>.</returns>
		public static CodeReference ToReference(this string referenceName, Assembly[] assemblies)
		{
			if (referenceName.IsEmpty())
				throw new ArgumentNullException("referenceName");

			if (assemblies == null)
				throw new ArgumentNullException("assemblies");

			var asm = assemblies.FirstOrDefault(a => a.ManifestModule.Name == referenceName + ".dll");

			if (asm == null)
			{
				try
				{
					asm = Assembly.Load(referenceName);
				}
				catch (FileNotFoundException)
				{
					return null;
				}
			}

			return new CodeReference
			{
				Name = referenceName,
				Location = asm.Location
			};
		}
Ejemplo n.º 2
0
 public Assembly Detect(Assembly[] loadedAssemblies)
 {
     return loadedAssemblies.FirstOrDefault(a => a.FullName.StartsWith(frameworkAssemblyName, StringComparison.OrdinalIgnoreCase));
 }