/// <summary>
        /// Загрузить классы, реализующие интерфейс
        /// </summary>
        public void GetTypes()
        {
            var t             = typeof(ITool);
            var assemblyTypes = AppDomain.CurrentDomain.GetAssemblies()
                                .SelectMany(typ => typ.GetTypes())
                                .Where(x => t.IsAssignableFrom(x));
            //на всякий случай избавляемся от интерфейсов
            List <Type> toolTypes = new List <Type>();

            foreach (Type type in assemblyTypes)
            {
                if (type.IsInterface || type.IsAbstract)
                {
                    continue;
                }
                else
                {
                    toolTypes.Add(type);
                }
            }
            foreach (Type type in toolTypes)
            {
                ITool plugin = (ITool)Activator.CreateInstance(type);
                ToolList.Add(plugin);
            }
            // Пусть первый инструмент будет выбран по умолчанию!
            ToolList[0].Select();
            SelectedTool = ToolList[0];
        }
Beispiel #2
0
        public void AddDialog(string title,
                              string command,
                              string arguments,
                              string initialDirectory,
                              bool isImmediateOutput,
                              string selectedReport,
                              string argsCollectorDllPath,
                              string argsCollectorType,
                              string toolDirPath,
                              string packageVersion,
                              string packageIdentifier,
                              string packageName)
        {
            ToolDescription newTool;

            if (ToolDescription.IsWebPageCommand(command))
            {
                newTool = new ToolDescription(GetTitle(title), command, arguments, string.Empty, false,
                                              selectedReport, argsCollectorDllPath, argsCollectorType, toolDirPath, null, packageVersion, packageIdentifier, packageName);
            }
            else
            {
                newTool = new ToolDescription(GetTitle(title), command, arguments, initialDirectory, isImmediateOutput,
                                              selectedReport, argsCollectorDllPath, argsCollectorType, toolDirPath, null, packageVersion, packageIdentifier, packageName);
            }
            ToolList.Add(newTool);
            RefreshListBox();
            PreviouslySelectedIndex = -1;
            listTools.SelectedIndex = ToolList.Count - 1;
            btnRemove.Enabled       = true;
        }
Beispiel #3
0
 public bool AddTool(ITool tool)
 {
     if (ToolsDic != null)
     {
         if (!ToolsDic.ContainsKey(tool.ToolName))
         {
             ToolsDic.Add(tool.ToolName, tool);
             ToolList.Add(tool);
             return(true);
         }
     }
     return(false);
 }