Пример #1
0
        private Tuple <PluginLoadContext, IEnumerable <Assembly> > Load(string path, LoadStrategyEnum multiple)
        {
            if (!Directory.Exists(path))
            {
                throw new PluginException($"[{nameof(Load)}] The given path does not exist, path: {path}");
            }

            if (multiple == LoadStrategyEnum.Multiple)
            {
                return(_pluginFinderService.GetAssembliesAndLoadContext(path));
            }

            var(pluginLoadContext, assembly) = _pluginFinderService.GetAssemblyAndLoadContext(path);
            return(new Tuple <PluginLoadContext, IEnumerable <Assembly> >(pluginLoadContext, new[] { assembly }));
        }
Пример #2
0
 public PluginLoadCommand(LoadStrategyEnum loadStrategyMultiple, string path)
 {
     LoadStrategyMultiple = loadStrategyMultiple;
     Path = path;
 }
Пример #3
0
 public PluginLoadCommand(LoadStrategyEnum loadStrategyMultiple) : this(loadStrategyMultiple, string.Empty)
 {
 }
Пример #4
0
        /// <inheritdoc cref="IPluginLoadService{T}.LoadAndAddToHomeAsync"/>
        public async Task <bool> LoadAndAddToHomeAsync(IEnumerable <string> assemblyPaths, LoadStrategyEnum multiple)
        {
            var paths = assemblyPaths.ToList();

            if (paths.IsNullOrEmpty())
            {
                return(false);
            }
            foreach (var path in paths)
            {
                (PluginLoadContext pluginLoadContext, IEnumerable <Assembly> assemblies) = Load(path, multiple);
                foreach (var assembly in assemblies)
                {
                    await AddToHome(_pluginCreator.CreateIPluginsFromAssembly(assembly), assembly);
                }
                pluginLoadContext.Unload();
            }
            return(true);
        }