Example #1
0
        private static LauncherErrorCode ProcessAction(LauncherArguments args)
        {
            var result = LauncherErrorCode.UnknownError;

            foreach (var action in args.Actions)
            {
                switch (action)
                {
                case LauncherArguments.ActionType.Run:
                    result = TryRun();
                    break;

                case LauncherArguments.ActionType.Uninstall:
                    result = Uninstall();
                    break;

                default:
                    // Unknown action
                    return(LauncherErrorCode.UnknownError);
                }
                if (IsError(result))
                {
                    return(result);
                }
            }
            return(result);
        }
        private static LauncherArguments ProcessArguments()
        {
            var result = new LauncherArguments
            {
                // Default action is to run the server
                Actions = new List <LauncherArguments.ActionType> {
                    LauncherArguments.ActionType.Run
                }
            };

            // Environment.GetCommandLineArgs correctly process arguments regarding the presence of '\' and '"'
            var args = Environment.GetCommandLineArgs().Skip(1).ToArray();

            foreach (var arg in args)
            {
                if (string.Equals(arg, "/Uninstall", StringComparison.InvariantCultureIgnoreCase))
                {
                    // No other action possible when uninstalling.
                    result.Actions.Clear();
                    result.Actions.Add(LauncherArguments.ActionType.Uninstall);
                }
            }

            return(result);
        }
Example #3
0
        private static LauncherArguments ProcessArguments(string[] args)
        {
            var result = new LauncherArguments
            {
                // Default action is to run the server
                Actions = new List <LauncherArguments.ActionType> {
                    LauncherArguments.ActionType.Run
                }
            };

            foreach (var arg in args)
            {
                if (string.Equals(arg, "/Uninstall", StringComparison.InvariantCultureIgnoreCase))
                {
                    // No other action possible when uninstalling.
                    result.Actions.Clear();
                    result.Actions.Add(LauncherArguments.ActionType.Uninstall);
                }
            }

            return(result);
        }