Example #1
0
 public override void OnEnteredState()
 {
     this.zipTempName = Path.GetTempFileName() + ".zip";
     try
     {
         bool flag;
         if (OS.VerifyFrameworkVersion(this.downloadMe.NetFxMajorVersion, this.downloadMe.NetFxMinorVersion, this.downloadMe.NetFxServicePack, true))
         {
             flag = false;
         }
         else
         {
             flag = true;
         }
         base.OnProgress(0.0);
         FileStream underlyingStream = new FileStream(this.zipTempName, FileMode.Create, FileAccess.Write, FileShare.Read);
         try
         {
             SiphonStream output = new SiphonStream(underlyingStream);
             this.abortMeStream = output;
             ProgressEventHandler progressCallback = (sender, e) => base.OnProgress(e.Percent);
             WebHelpers.DownloadFile(new Uri(this.downloadMe.ChooseDownloadUrl(flag)), output, progressCallback);
             output.Flush();
             this.abortMeStream = null;
             output             = null;
         }
         finally
         {
             if (underlyingStream != null)
             {
                 underlyingStream.Close();
                 underlyingStream = null;
             }
         }
         base.StateMachine.QueueInput(PrivateInput.GoToExtracting);
     }
     catch (Exception exception)
     {
         this.exception = exception;
         if (base.AbortRequested)
         {
             base.StateMachine.QueueInput(PrivateInput.GoToAborted);
         }
         else
         {
             this.exception = exception;
             base.StateMachine.QueueInput(PrivateInput.GoToError);
         }
     }
 }
Example #2
0
        public override void OnEnteredState()
        {
            this.zipTempName = Path.GetTempFileName() + ".zip";

            try
            {
                bool getFull;

                if (SystemLayer.OS.IsDotNetVersionInstalled(
                        downloadMe.NetFxVersion.Major,
                        downloadMe.NetFxVersion.Minor,
                        downloadMe.NetFxVersion.Build))
                {
                    getFull = false;
                }
                else
                {
                    getFull = true;
                }

                OnProgress(0.0);

                FileStream zipFileWrite = new FileStream(zipTempName, FileMode.Create, FileAccess.Write, FileShare.Read);

                try
                {
                    // we need to wrap the zipFileWrite in a SiphonStream so that we can
                    // Abort() it externally
                    SiphonStream monitorStream = new SiphonStream(zipFileWrite);
                    this.abortMeStream = monitorStream;

                    ProgressEventHandler progressCallback =
                        delegate(object sender, ProgressEventArgs e)
                        {
                            OnProgress(e.Percent);
                        };

                    string url;

                    url = downloadMe.ChooseDownloadUrl(getFull);
                    SystemLayer.Tracing.Ping("Chosen mirror url: " + url);

                    Utility.DownloadFile(new Uri(url), monitorStream, progressCallback);
                    monitorStream.Flush();

                    this.abortMeStream = null;
                    monitorStream = null;
                }

                finally
                {
                    if (zipFileWrite != null)
                    {
                        zipFileWrite.Close();
                        zipFileWrite = null;
                    }
                }

                StateMachine.QueueInput(PrivateInput.GoToExtracting);
            }

            catch (Exception ex)
            {
                this.exception = ex;

                if (this.AbortRequested)
                {
                    StateMachine.QueueInput(PrivateInput.GoToAborted);
                }
                else
                {
                    this.exception = ex;
                    StateMachine.QueueInput(PrivateInput.GoToError);
                }
            }
        }
Example #3
0
        public override void OnEnteredState()
        {
            this.zipTempName = Path.GetTempFileName() + ".zip";

            try
            {
                bool getFull;

                if (SystemLayer.OS.IsDotNetVersionInstalled(
                        downloadMe.NetFxMajorVersion,
                        downloadMe.NetFxMinorVersion,
                        downloadMe.NetFxServicePack,
                        true))
                {
                    getFull = false;
                }
                else
                {
                    getFull = true;
                }

                OnProgress(0.0);

                FileStream zipFileWrite = new FileStream(zipTempName, FileMode.Create, FileAccess.Write, FileShare.Read);

                try
                {
                    // we need to wrap the zipFileWrite in a SiphonStream so that we can
                    // Abort() it externally
                    SiphonStream monitorStream = new SiphonStream(zipFileWrite);
                    this.abortMeStream = monitorStream;

                    ProgressEventHandler progressCallback =
                        delegate(object sender, ProgressEventArgs e)
                    {
                        OnProgress(e.Percent);
                    };

                    string url;

                    url = downloadMe.ChooseDownloadUrl(getFull);
                    SystemLayer.Tracing.Ping("Chosen mirror url: " + url);

                    Utility.DownloadFile(new Uri(url), monitorStream, progressCallback);
                    monitorStream.Flush();

                    this.abortMeStream = null;
                    monitorStream      = null;
                }

                finally
                {
                    if (zipFileWrite != null)
                    {
                        zipFileWrite.Close();
                        zipFileWrite = null;
                    }
                }

                StateMachine.QueueInput(PrivateInput.GoToExtracting);
            }

            catch (Exception ex)
            {
                this.exception = ex;

                if (this.AbortRequested)
                {
                    StateMachine.QueueInput(PrivateInput.GoToAborted);
                }
                else
                {
                    this.exception = ex;
                    StateMachine.QueueInput(PrivateInput.GoToError);
                }
            }
        }