Beispiel #1
0
        async void LoadCmdletsForProject(ClosableTabItem tab)
        {
            String cmd = Utils.GetCommandTypes();

            if (String.IsNullOrEmpty(cmd))
            {
                Utils.MsgBox("Error", Strings.E_EmptyCmds, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (FileProcessor.FindModule(tab.Module.Name))
            {
                tab.Module.ModulePath = null;
            }
            tab.ErrorInfo = null;
            tab.EditorContext.CurrentCmdlet = null;
            List <CmdletObject> nativeCmdlets = new List <CmdletObject>();

            try {
                IEnumerable <CmdletObject> data = await PowerShellProcessor.EnumCmdlets(tab.Module, cmd, false);

                nativeCmdlets.AddRange(data);
                PowerShellProcessor.CompareCmdlets(tab.Module, nativeCmdlets);
            } catch (Exception e) {
                String message = e.Message + "\n\nYou still can use the module project in offline mode";
                message += "\nHowever certain functionality may not be available.";
                Utils.MsgBox("Error while loading cmdlets", message, MessageBoxButton.OK, MessageBoxImage.Error);
                tab.ErrorInfo = e.Message;
                foreach (CmdletObject cmdlet in tab.Module.Cmdlets)
                {
                    cmdlet.GeneralHelp.Status = ItemStatus.Missing;
                }
            } finally {
                UIManager.ShowEditor(tab);
            }
        }
Beispiel #2
0
        public async void LoadCmdlets(Object helpPath, Boolean importCBH)
        {
            ClosableTabItem previousTab     = _mwvm.SelectedTab;
            UIElement       previousElement = ((Grid)previousTab.Content).Children[0];
            String          cmd             = Utils.GetCommandTypes();

            if (String.IsNullOrEmpty(cmd))
            {
                Utils.MsgBox("Error", Strings.E_EmptyCmds, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            UIManager.ShowBusy(previousTab, Strings.InfoCmdletsLoading);
            try {
                IEnumerable <CmdletObject> data = await PowerShellProcessor.EnumCmdlets(_mwvm.SelectedModule, cmd, importCBH);

                _mwvm.SelectedModule.Cmdlets.Clear();
                foreach (CmdletObject item in data)
                {
                    _mwvm.SelectedModule.Cmdlets.Add(item);
                }
                if (helpPath != null)
                {
                    _mwvm.SelectedModule.ImportedFromHelp = true;
                    XmlProcessor.ImportFromXml((String)helpPath, _mwvm.SelectedModule);
                }
                previousTab.Module   = _mwvm.SelectedModule;
                _mwvm.SelectedModule = null;
                UIManager.ShowEditor(previousTab);
            } catch (Exception e) {
                Utils.MsgBox("Error while loading cmdlets", e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
                _mwvm.SelectedTab.ErrorInfo = e.Message;
                UIManager.RestoreControl(previousTab, previousElement);
            }
        }