Esempio n. 1
0
        /// <summary>
        /// Select a plugin manually.
        /// </summary>
        /// <returns>The manually selected plugin.</returns>
        private IFilePlugin GetManualSelection(IReadOnlyList <IFilePlugin> pluginList)
        {
            // 1. Request manual selection by the user
            var selectionArgs = new ManualSelectionEventArgs(pluginList);

            OnManualSelection?.Invoke(this, selectionArgs);

            return(selectionArgs.Result);
        }
Esempio n. 2
0
        // TODO: Maybe do not pass whole messages, since this message may not be universal for all UI's. Instead pass other atomic parameters  to signalize this behaviour.
        /// <summary>
        /// Select a plugin manually.
        /// </summary>
        /// <returns>The manually selected plugin.</returns>
        private IFilePlugin GetManualSelection(string message, IReadOnlyList <IFilePlugin> filePluginList, string filterNote, IReadOnlyList <IFilePlugin> filteredPluginList)
        {
            // 1. Request manual selection by the user
            var selectionArgs = new ManualSelectionEventArgs(message, filePluginList, filterNote, filteredPluginList);

            OnManualSelection?.Invoke(this, selectionArgs);

            return(selectionArgs.Result);
        }
Esempio n. 3
0
        /// <summary>
        /// Select a plugin manually.
        /// </summary>
        /// <returns>The manually selected plugin.</returns>
        private IFilePlugin GetManualSelection()
        {
            // 1. Get all plugins that don't implement IIdentifyFile
            var nonIdentifiablePlugins = _filePluginLoaders.GetNonIdentifiableFilePlugins().ToArray();

            // 2. Request manual selection by the user
            var selectionArgs = new ManualSelectionEventArgs(nonIdentifiablePlugins);

            OnManualSelection?.Invoke(this, selectionArgs);

            return(selectionArgs.Result);
        }
Esempio n. 4
0
        private static void PluginManager_OnManualSelection(object sender, ManualSelectionEventArgs e)
        {
            Console.WriteLine("No plugin could identify the file!");
            Console.WriteLine("Select a plugin manually:");

            foreach (var filePlugin in e.FilePlugins)
            {
                Console.WriteLine($"[{filePlugin.PluginId}] - {filePlugin.Metadata.Name} | {string.Join(';', filePlugin.FileExtensions)}");
            }

            var idArgument = _argumentGetter.GetNextArgument();

            if (!Guid.TryParse(idArgument, out var pluginId))
            {
                Console.WriteLine($"'{idArgument}' is not a valid plugin ID.");
                e.Result = null;
                return;
            }

            Console.Clear();
            e.Result = e.FilePlugins.FirstOrDefault(x => x.PluginId == pluginId);
        }
Esempio n. 5
0
 private void FileLoader_OnManualSelection(object sender, ManualSelectionEventArgs e)
 {
     OnManualSelection?.Invoke(sender, e);
 }