コード例 #1
0
        /// <summary>
        /// Creates a <see cref="PathAssemblyResolver"/> from the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>PathAssemblyResolver.</returns>
        /// <exception cref="DirectoryNotFoundException"></exception>
        public static PathAssemblyResolver Create(string path)
        {
            if (!Directory.Exists(path))
            {
                throw new DirectoryNotFoundException(path);
            }

            IEnumerable <string> assemblyPaths = Directory.EnumerateFiles(path, "*.dll", SearchOption.TopDirectoryOnly);

            return(new PathAssemblyResolver(StaticAssemblyResolver.Create(assemblyPaths)));
        }
コード例 #2
0
        /// <summary>
        /// Creates a <see cref="AssemblyResolutionManager"/> from the specified assembly lookup paths and options.
        /// </summary>
        /// <param name="assemblyLookupPaths">The assembly lookup paths.</param>
        /// <param name="transformerOptions">The transformer options.</param>
        /// <returns>A <see cref="AssemblyResolutionManager"/>.</returns>
        public static AssemblyResolutionManager Create(IEnumerable <string> assemblyLookupPaths, SymbioticTransformerOptions transformerOptions)
        {
            AssemblyResolutionManager assemblyResolver = AssemblyResolutionManager.CreateDefault();

            if (!string.IsNullOrEmpty(transformerOptions.AssemblyReferencesFilePath))
            {
                string[] assemblyPaths = File.ReadAllLines(transformerOptions.AssemblyReferencesFilePath);
                assemblyResolver.AddAssemblyResolver(StaticAssemblyResolver.Create(assemblyPaths));
            }

            foreach (string lookupPath in assemblyLookupPaths)
            {
                assemblyResolver.AddAssemblyResolver(PathAssemblyResolver.Create(Path.GetDirectoryName(lookupPath)));
            }

            return(assemblyResolver);
        }