/// <summary> /// Function to load in a plug in assembly. /// </summary> private void DoLoadPlugInAssembly() { try { string lastCodecPath = _settings.LastCodecPlugInPath.FormatDirectory(Path.DirectorySeparatorChar); if ((string.IsNullOrWhiteSpace(lastCodecPath)) || (!Directory.Exists(lastCodecPath))) { lastCodecPath = AppDomain.CurrentDomain.BaseDirectory; } _openCodecDialog.DialogTitle = Resources.GORSPR_CAPTION_SELECT_CODEC_DLL; _openCodecDialog.FileFilter = Resources.GORSPR_FILTER_SELECT_CODEC; _openCodecDialog.InitialDirectory = new DirectoryInfo(lastCodecPath); string path = _openCodecDialog.GetFilename(); if ((string.IsNullOrWhiteSpace(path)) || (!File.Exists(path))) { return; } _busyService.SetBusy(); IReadOnlyList <GorgonSpriteCodecPlugIn> codecs = _codecs.AddCodecPlugIn(path, out IReadOnlyList <string> errors); if (errors.Count > 0) { _messageDisplay.ShowError(Resources.GORSPR_ERR_CODEC_LOAD_ERRORS_PRESENT, details: string.Join("\n\n", errors.Select((item, index) => $"Error #{index + 1}\n--------------\n{item}"))); if (codecs.Count == 0) { return; } } foreach (GorgonSpriteCodecPlugIn plugin in codecs) { foreach (GorgonSpriteCodecDescription desc in plugin.Codecs) { IGorgonSpriteCodec codec = _codecs.Codecs.FirstOrDefault(item => string.Equals(item.GetType().FullName, desc.Name, StringComparison.OrdinalIgnoreCase)); if (codec == null) { continue; } CodecPlugInPaths.Add(new CodecSetting(codec.CodecDescription, plugin, desc)); } } _settings.LastCodecPlugInPath = Path.GetDirectoryName(path).FormatDirectory(Path.DirectorySeparatorChar); // Store the settings now. DoWriteSettings(); } catch (Exception ex) { _messageDisplay.ShowError(ex, Resources.GORSPR_ERR_CANNOT_LOAD_CODEC); } finally { _busyService.SetIdle(); } }