Beispiel #1
0
        private UpdateStartupContext ParseArgs(string[] args)
        {
            if (args == null || !args.Any())
            {
                throw new ArgumentOutOfRangeException("args", "args must be specified");
            }

            var startupContext = new UpdateStartupContext
                                 {
                                     ProcessId = ParseProcessId(args[0])
                                 };

            if (args.Count() == 1)
            {
                return startupContext;
            }

            if (args.Count() >= 3)
            {
                startupContext.UpdateLocation = args[1];
                startupContext.ExecutingApplication = args[2];
            }

            return startupContext;
        }
Beispiel #2
0
        private string GetInstallationDirectory(UpdateStartupContext startupContext)
        {
            if (startupContext.ExecutingApplication.IsNullOrWhiteSpace())
            {
                Logger.Debug("Using process ID to find installation directory: {0}", startupContext.ProcessId);
                var exeFileInfo = new FileInfo(_processProvider.GetProcessById(startupContext.ProcessId).StartPath);
                Logger.Debug("Executable location: {0}", exeFileInfo.FullName);

                return(exeFileInfo.DirectoryName);
            }
            else
            {
                Logger.Debug("Using executing application: {0}", startupContext.ExecutingApplication);
                var exeFileInfo = new FileInfo(startupContext.ExecutingApplication);
                Logger.Debug("Executable location: {0}", exeFileInfo.FullName);

                return(exeFileInfo.DirectoryName);
            }
        }
Beispiel #3
0
        private UpdateStartupContext ParseArgs(string[] args)
        {
            if (args == null || !args.Any())
            {
                throw new ArgumentOutOfRangeException("args", "args must be specified");
            }

            var startupContext = new UpdateStartupContext
            {
                ProcessId = ParseProcessId(args[0])
            };

            if (OsInfo.IsMono)
            {
                if (args.Count() == 1)
                {
                    return(startupContext);
                }

                else if (args.Count() == 3)
                {
                    startupContext.UpdateLocation       = args[1];
                    startupContext.ExecutingApplication = args[2];
                }

                else
                {
                    logger.Debug("Arguments:");

                    foreach (var arg in args)
                    {
                        logger.Debug("  {0}", arg);
                    }

                    var message = String.Format("Number of arguments are unexpected, expected: 3, found: {0}", args.Count());

                    throw new ArgumentOutOfRangeException("args", message);
                }
            }

            return(startupContext);
        }
Beispiel #4
0
        private string GetInstallationDirectory(UpdateStartupContext startupContext)
        {
            if (startupContext.ExecutingApplication.IsNullOrWhiteSpace())
            {
                Logger.Debug("Using process ID to find installation directory: {0}", startupContext.ProcessId);
                var exeFileInfo = new FileInfo(_processProvider.GetProcessById(startupContext.ProcessId).StartPath);
                Logger.Debug("Executable location: {0}", exeFileInfo.FullName);

                return exeFileInfo.DirectoryName;
            }

            else
            {
                Logger.Debug("Using executing application: {0}", startupContext.ExecutingApplication);
                var exeFileInfo = new FileInfo(startupContext.ExecutingApplication);
                Logger.Debug("Executable location: {0}", exeFileInfo.FullName);

                return exeFileInfo.DirectoryName;
            }
        }
Beispiel #5
0
        private UpdateStartupContext ParseArgs(string[] args)
        {
            if (args == null || !args.Any())
            {
                throw new ArgumentOutOfRangeException("args", "args must be specified");
            }

            var startupContext = new UpdateStartupContext
            {
                ProcessId = ParseProcessId(args[0])
            };

            if (OsInfo.IsNotWindows)
            {
                switch (args.Count())
                {
                case 1:
                    return(startupContext);

                default:
                {
                    Logger.Debug("Arguments:");

                    foreach (var arg in args)
                    {
                        Logger.Debug("  {0}", arg);
                    }

                    startupContext.UpdateLocation       = args[1];
                    startupContext.ExecutingApplication = args[2];

                    break;
                }
                }
            }

            return(startupContext);
        }
Beispiel #6
0
        private UpdateStartupContext ParseArgs(string[] args)
        {
            if (args == null || !args.Any())
            {
                throw new ArgumentOutOfRangeException("args", "args must be specified");
            }

            var startupContext = new UpdateStartupContext
                                 {
                                     ProcessId = ParseProcessId(args[0])
                                 };

            if (OsInfo.IsNotWindows)
            {
                switch (args.Count())
                {
                    case 1:
                        return startupContext;
                    default:
                        {
                            Logger.Debug("Arguments:");

                            foreach (var arg in args)
                            {
                                Logger.Debug("  {0}", arg);
                            }

                            startupContext.UpdateLocation = args[1];
                            startupContext.ExecutingApplication = args[2];

                            break;
                        }
                }
            }

            return startupContext;
        }
Beispiel #7
0
        private UpdateStartupContext ParseArgs(string[] args)
        {
            if (args == null || !args.Any())
            {
                throw new ArgumentOutOfRangeException("args", "args must be specified");
            }

            var startupContext = new UpdateStartupContext
                                 {
                                     ProcessId = ParseProcessId(args[0])
                                 };

            if (OsInfo.IsMono)
            {
                if (args.Count() == 1)
                {
                    return startupContext;
                }

                else if (args.Count() == 3)
                {
                    startupContext.UpdateLocation = args[1];
                    startupContext.ExecutingApplication = args[2];
                }

                else
                {
                    logger.Debug("Arguments:");

                    foreach (var arg in args)
                    {
                        logger.Debug("  {0}", arg);
                    }

                    var message = String.Format("Number of arguments are unexpected, expected: 3, found: {0}", args.Count());

                    throw new ArgumentOutOfRangeException("args", message);
                }
            }

            return startupContext;
        }