Exemplo n.º 1
0
        /// <summary>
        /// Create a plugin loader for an assembly file.
        /// </summary>
        /// <param name="assemblyFile">The file path to the main assembly for the plugin.</param>
        /// <param name="configure">A function which can be used to configure advanced options for the plugin loader.</param>
        /// <returns>A loader.</returns>
        public static PluginLoader CreateFromAssemblyFile(string assemblyFile, Action <LoaderConfig> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var config = new LoaderConfig(assemblyFile);

            configure(config);
            return(new PluginLoader(config));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PluginLoader"/> class.
 /// </summary>
 /// <param name="config">The configuration for the plugin.</param>
 public PluginLoader(LoaderConfig config)
 {
     this.config         = config ?? throw new ArgumentNullException(nameof(config));
     this.contextBuilder = CreateLoadContextBuilder(config);
     this.context        = (ManagedLoadContext)this.contextBuilder.Build();
 }