Exemplo n.º 1
0
        private static IState GetState(this RunTypes type, string runLocation = null)
        {
            switch (type)
            {
            case RunTypes.Clone:
                return(new CloneState(runLocation));

            case RunTypes.LocalRevert:
                return(new LocalRevertState(runLocation));

            case RunTypes.Reclone:
                return(new ReCloneState(runLocation));

            case RunTypes.Update:
                return(new UpdateState(runLocation));

            case RunTypes.Settings:
                return(new SettingsState());

            case RunTypes.Setup:
                return(new SetupState());

            case RunTypes.Uninstall:
                return(new UninstallState());

            default:
                throw new NotImplementedException($"The runType {type.ToString()} has not been implemented.");
            }
        }
Exemplo n.º 2
0
        //  Extension Methods
        //  =================

        public static void Open(this RunTypes type, string[] args)
        {
            switch (type)
            {
            case RunTypes.Clone:
            case RunTypes.LocalRevert:
            case RunTypes.Reclone:
            case RunTypes.Update:
                string runLocation;

                if (args.Length > 0)
                {
                    runLocation = args[0];
                }
                else if (CommonFileDialog.IsPlatformSupported)
                {
                    runLocation = SelectWinVistaFolder();
                }
                else
                {
                    runLocation = SelectWinXPFolder();
                }

                if (!Directory.Exists(runLocation))
                {
                    System.Windows.MessageBox.Show("Given location is not a valid directory!",
                                                   "Command Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                    return;
                }

                IState state = type.GetState(runLocation);
                state.InitialActions(args);

                OpenMainWindow(state);
                return;

            case RunTypes.Settings:
            case RunTypes.Setup:
            case RunTypes.Uninstall:
                type.GetState().InitialActions(args);
                return;

            default:
                throw new NotImplementedException($"The runType {type.ToString()} has not been implemented.");
            }
        }