Exemple #1
0
 private void pluginList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (pluginList.SelectedItems.Count > 0)
     {
         ChosenAdapter = (ILoadFiles)pluginList.SelectedItems[0].Tag;
     }
 }
Exemple #2
0
        /// <summary>
        /// Does the actual identification with IIdentifyFiles and checks the availablity of the data stream.
        /// </summary>
        /// <param name="adapter">Adapter to identify with.</param>
        /// <param name="kli">Kore information for identification.</param>
        /// <returns>Returns if the adapter was capable of identifying the file.</returns>
        private bool CheckAdapter(ILoadFiles adapter, KoreLoadInfo kli)
        {
            if (!(adapter is IIdentifyFiles iif))
            {
                return(false);
            }
            adapter.LeaveOpen = true;

            kli.FileData.Position = 0;
            var info = new StreamInfo {
                FileData = kli.FileData, FileName = kli.FileName
            };
            var res = iif.Identify(info, kli.FileSystem);

            if (!kli.FileData.CanRead)
            {
                throw new InvalidOperationException($"Plugin with ID '{_pluginLoader.GetMetadata<PluginInfoAttribute>(adapter).ID}' closed the stream(s) while identifying the file(s).");
            }

            return(res);
        }