コード例 #1
0
        private FeedUri ResolveAlias(string aliasName)
        {
            AppEntry appEntry;

            AddAlias.GetAppAlias(AppList, aliasName, out appEntry);
            if (appEntry == null)
            {
                throw new UriFormatException(string.Format(Resources.AliasNotFound, aliasName));
            }
            return(appEntry.InterfaceUri);
        }
コード例 #2
0
        private static FeedUri ResolveAlias(string aliasName)
        {
            var appList = AppList.LoadSafe();

            AppEntry appEntry;

            AddAlias.GetAppAlias(appList, aliasName, out appEntry);
            if (appEntry?.InterfaceUri == null)
            {
                throw new UriFormatException(string.Format(Resources.AliasNotFound, aliasName));
            }
            return(appEntry.InterfaceUri);
        }
コード例 #3
0
ファイル: AddAliasTest.cs プロジェクト: Olezhka/Hipbot
 public void SetUp()
 {
     handler = Create<AddAlias>();
 }
コード例 #4
0
        /// <summary>
        /// Runs the application (called by main method or by embedding process).
        /// </summary>
        public static ExitCode Run(string[] args)
        {
            var handler = new CliCommandHandler();

            try
            {
                var command = new AddAlias(handler);
                command.Parse(args);
                return(command.Execute());
            }
            #region Error handling
            catch (OperationCanceledException)
            {
                return(ExitCode.UserCanceled);
            }
            catch (NeedGuiException ex)
            {
                if (ProgramUtils.GuiAssemblyName == null)
                {
                    Log.Error(ex);
                    return(ExitCode.InvalidArguments);
                }
                else
                {
                    Log.Info("Switching to GUI");
                    try
                    {
                        return((ExitCode)ProcessUtils.Assembly(ProgramUtils.GuiAssemblyName, args.Prepend(AddAlias.Name)).Run());
                    }
                    #region Error handling
                    catch (OperationCanceledException)
                    {
                        return(ExitCode.UserCanceled);
                    }
                    catch (IOException ex2)
                    {
                        Log.Error(ex2);
                        return(ExitCode.IOError);
                    }
                    #endregion
                }
            }
            catch (NotAdminException ex)
            {
                if (WindowsUtils.IsWindowsNT)
                {
                    try
                    {
                        return((ExitCode)ProcessUtils.Assembly(ProgramUtils.GuiAssemblyName ?? "0install", args.Prepend(AddAlias.Name)).AsAdmin().Run());
                    }
                    #region Error handling
                    catch (OperationCanceledException)
                    {
                        return(ExitCode.UserCanceled);
                    }
                    catch (IOException ex2)
                    {
                        Log.Error(ex2);
                        return(ExitCode.IOError);
                    }
                    #endregion
                }
                else
                {
                    Log.Error(ex);
                    return(ExitCode.AccessDenied);
                }
            }
            catch (OptionException ex)
            {
                var builder = new StringBuilder(ex.Message);
                if (ex.InnerException != null)
                {
                    builder.Append("\n" + ex.InnerException.Message);
                }
                builder.Append("\n" + string.Format(Resources.TryHelp, ExeName));
                Log.Error(builder.ToString());
                return(ExitCode.InvalidArguments);
            }
            catch (FormatException ex)
            {
                Log.Error(ex);
                return(ExitCode.InvalidArguments);
            }
            catch (WebException ex)
            {
                Log.Error(ex);
                return(ExitCode.WebError);
            }
            catch (NotSupportedException ex)
            {
                Log.Error(ex);
                return(ExitCode.NotSupported);
            }
            catch (IOException ex)
            {
                Log.Error(ex);
                return(ExitCode.IOError);
            }
            catch (UnauthorizedAccessException ex)
            {
                Log.Error(ex);
                return(ExitCode.AccessDenied);
            }
            catch (InvalidDataException ex)
            {
                Log.Error(ex);
                return(ExitCode.InvalidData);
            }
            catch (SignatureException ex)
            {
                Log.Error(ex);
                return(ExitCode.InvalidSignature);
            }
            catch (DigestMismatchException ex)
            {
                Log.Error(ex);
                return(ExitCode.DigestMismatch);
            }
            catch (SolverException ex)
            {
                Log.Error(ex);
                return(ExitCode.SolverError);
            }
            #endregion

            finally
            {
                handler.CloseUI();
            }
        }