Beispiel #1
0
        public async Task <bool> AddOrRemoveTerminal(TerminalModel terminal, string packageName)
        {
            bool isChanged   = false;
            bool isInstalled = await PackageHelper.IsAppInstalledAsync(packageName);

            //Ensure terminal is not already in List
            if (Terminals.FirstOrDefault(x => x.Path.Equals(terminal.Path, StringComparison.OrdinalIgnoreCase)) == null && isInstalled)
            {
                Terminals.Add(terminal);
                isChanged = true;
            }
            else if (!isInstalled)
            {
                if (string.IsNullOrWhiteSpace(DefaultTerminalPath))
                {
                    ResetToDefaultTerminal();
                }
                else if (DefaultTerminalPath.Equals(terminal.Path, StringComparison.OrdinalIgnoreCase))
                {
                    ResetToDefaultTerminal();
                }
                Terminals.Remove(Terminals.FirstOrDefault(x => x.Path.Equals(terminal.Path, StringComparison.OrdinalIgnoreCase)));

                isChanged = true;
            }
            return(isChanged);
        }
Beispiel #2
0
        public TerminalModel GetDefaultTerminal()
        {
            TerminalModel terminal = Terminals.FirstOrDefault(x => x.Path.Equals(DefaultTerminalPath, StringComparison.OrdinalIgnoreCase));

            if (terminal != null)
            {
                return(terminal);
            }
            else
            {
                ResetToDefaultTerminal();
            }

            return(Terminals.First());
        }