Exemplo n.º 1
0
        public Root()
        {
            InstalledWebSites = new Dictionary <string, WebSite>(StringComparer.OrdinalIgnoreCase);
            UseIisExpress     = IsClient();
            Application.Current.SessionEnding += Current_SessionEnding;
            Dispatcher = Dispatcher.CurrentDispatcher;
            Tasks      = new ObservableCollection <InstallerTask>();
            Summary    = new ObservableCollection <Summary>();

            _demoDbStep = new Step(this)
            {
                Name = "DemoDbSettings", Caption = "Database Settings"
            };

            ConnectionString = new ConnectionString();

            Steps = new ObservableCollection <Step>
            {
                new Step(this)
                {
                    Name = "Welcome", Caption = "Welcome"
                },
                new Step(this, PrepareInstall)
                {
                    Name = "SelectComponents", Caption = "Select Components"
                },
                new Step(this, Install)
                {
                    Name = "Installation", Caption = "Installation"
                },
                new Step(this, Finished, Finishing)
                {
                    Name = "Finished", Caption = "Finished"
                }
            };

            CurrentStep = Steps[0];

            Next = new Command(
                () => new Thread(new ThreadStart(delegate
            {
                if (!CurrentStep.Execute())
                {
                    Dispatcher.Invoke(new Action(() =>
                    {
                        Next.RaiseEvent();
                        Back.RaiseEvent();
                    }));
                    return;
                }

                Dispatcher.Invoke(new Action(() =>
                {
                    CurrentStep = Steps[Steps.IndexOf(CurrentStep) + 1];
                    Next.RaiseEvent();
                    Back.RaiseEvent();
                }));
            })).Start(),

                () => !CurrentStep.IsExecuting && CurrentStep != Steps[Steps.Count - 1]);

            Back = new Command(() =>
            {
                CurrentStep = Steps[Steps.IndexOf(CurrentStep) - 1];
                Next.RaiseEvent();
                Back.RaiseEvent();
            }, () => !CurrentStep.IsExecuting && CurrentStep != Steps[0]);

            Cancel = new Command(() =>
            {
                if (ConfirmExit())
                {
                    Application.Current.Shutdown();
                }
            }, () => !CurrentStep.IsExecuting);

            End = new Command(() => Application.Current.Shutdown(), () => IsEnded);

            Instance = this;

            if (ModelSerilisation.Deserialize(this))
            {
                // The installer has been resumed.
                // TODO: what do?
            }
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 protected override TOutput ExecuteSubPipeline(TInput input, PipelineContext ctx)
 {
     return(CurrentStep.Execute(input, ctx));
 }