private void LoadAndAddFromExternal(string dllToLoad)
        {
            _probePath = Path.GetDirectoryName(dllToLoad);
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
            try
            {
                var group = new FormatterGroup();
                group.Name = Path.GetFileName(dllToLoad);
                FormatterGroups.Add(group);

                var assembly   = Assembly.Load(File.ReadAllBytes(dllToLoad));
                var enumerable = assembly.GetTypes().Where(e => e.GetMethods().Any(w => w.CustomAttributes.Any(f =>
                                                                                                               f.AttributeType.Namespace == typeof(MorestachioFormatterAttribute).Namespace &&
                                                                                                               f.AttributeType.Name == typeof(MorestachioFormatterAttribute).Name)));

                foreach (var type in enumerable)
                {
                    foreach (var method in type.GetMethods(BindingFlags.Static | BindingFlags.Public))
                    {
                        foreach (var customAttribute in method.GetCustomAttributes <MorestachioFormatterAttribute>())
                        {
                            if (customAttribute != null)
                            {
                                var name          = customAttribute.Name;
                                var description   = customAttribute.Description;
                                var parameterType = method.GetParameters().FirstOrDefault()?.ParameterType;
                                var outputType    = customAttribute.OutputType;
                                if ((object)outputType == null)
                                {
                                    outputType = method.ReturnType;
                                }

                                var array = method
                                            .GetCustomAttributes <MorestachioFormatterInputAttribute>().Select(e =>
                                                                                                               new InputDescription(e.Description, e.OutputType, e.Example)).ToArray();
                                var returnHint         = customAttribute.ReturnHint;
                                var function           = method;
                                var formatterViewModel = new ExternalFormatterViewModel(_service, dllToLoad, function);
                                formatterViewModel.Name       = name;
                                formatterViewModel.InputType  = parameterType;
                                formatterViewModel.OutputType = outputType;
                                group.Formatters.Add(formatterViewModel);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, $"Could not load dll '{dllToLoad}'");
            }
            finally
            {
                AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
            }
        }
 private bool CanRemoveFormatterExecute(FormatterGroup sender)
 {
     return(true);
 }
 private void RemoveFormatterExecute(FormatterGroup sender)
 {
     FormatterGroups.Remove(sender);
 }