Beispiel #1
0
        /// <summary>
        /// Build the reflection data
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private async void btnBuild_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnBuild.IsEnabled    = false;
                pbProgress.Visibility = System.Windows.Visibility.Visible;

                cancellationTokenSource = new CancellationTokenSource();

                using (var bp = new BuildProcess(dataSet)
                {
                    CancellationToken = cancellationTokenSource.Token,
                    ProgressProvider = new Progress <string>(this.ReportProgress)
                })
                {
                    await Task.Run(() => bp.Build(), cancellationTokenSource.Token);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                txtBuildOutput.AppendText("\r\n\r\nUnable to generate reflection data files: " + ex.Message + "\r\n");
                txtBuildOutput.CaretIndex = txtBuildOutput.Text.Length;
                txtBuildOutput.ScrollToEnd();
            }
            finally
            {
                btnBuild.IsEnabled    = true;
                pbProgress.Visibility = System.Windows.Visibility.Hidden;

                if (cancellationTokenSource != null)
                {
                    if (cancellationTokenSource.IsCancellationRequested)
                    {
                        this.Close();
                    }

                    cancellationTokenSource.Dispose();
                    cancellationTokenSource = null;
                }
            }
        }
Beispiel #2
0
        //=====================================================================

        /// <summary>
        /// Build the reflection data based on the command line arguments
        /// </summary>
        /// <param name="arguments">The command line arguments</param>
        /// <returns>Zero if successful, or a non-zero value on failure</returns>
        private int PerformBuild(ParseArgumentsResult arguments)
        {
            ReflectionDataSetDictionary rdsd;
            ReflectionDataSet           dataSet;
            Version version = new Version();
            string  platform;
            int     exitCode = 0;

            try
            {
                platform = (string)arguments.Options["platform"].Value;

                if (arguments.Options["version"].IsPresent && !Version.TryParse(
                        (string)arguments.Options["version"].Value, out version))
                {
                    Console.WriteLine("Invalid version value");
                    return(1);
                }

                if (arguments.Options["path"].IsPresent)
                {
                    rdsd = new ReflectionDataSetDictionary((string[])arguments.Options["path"].Value);
                }
                else
                {
                    rdsd = new ReflectionDataSetDictionary(null);
                }

                if (version.Major != 0)
                {
                    dataSet = rdsd.CoreFrameworkMatching(platform, version, true);
                }
                else
                {
                    dataSet = rdsd.CoreFrameworkMostRecent(platform);
                }

                if (dataSet == null)
                {
                    Console.WriteLine("A suitable framework could not be found for the given parameters");
                    return(1);
                }

                Console.WriteLine("Building reflection data for {0} found in {1}", dataSet.Title,
                                  dataSet.Filename);

                using (var bp = new BuildProcess(dataSet)
                {
                    ProgressProvider = this
                })
                {
                    bp.Build();
                }
            }
            catch (Exception ex)
            {
                exitCode = 1;
                Debug.WriteLine(ex.ToString());
                Console.WriteLine("\r\n\r\nUnable to generate reflection data files: " + ex.Message + "\r\n");
            }

            return(exitCode);
        }
        /// <summary>
        /// Build the reflection data
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private async void btnBuild_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                btnBuild.IsEnabled = false;
                pbProgress.Visibility = System.Windows.Visibility.Visible;

                cancellationTokenSource = new CancellationTokenSource();

                using(var bp = new BuildProcess(dataSet)
                    {
                        CancellationToken = cancellationTokenSource.Token,
                        ProgressProvider = new Progress<string>(this.ReportProgress)
                    })
                {
                    await Task.Run(() => bp.Build(), cancellationTokenSource.Token);
                }
            }
            catch(Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
                txtBuildOutput.AppendText("\r\n\r\nUnable to generate reflection data files: " + ex.Message + "\r\n");
                txtBuildOutput.CaretIndex = txtBuildOutput.Text.Length;
                txtBuildOutput.ScrollToEnd();
            }
            finally
            {
                btnBuild.IsEnabled = true;
                pbProgress.Visibility = System.Windows.Visibility.Hidden;

                if(cancellationTokenSource != null)
                {
                    if(cancellationTokenSource.IsCancellationRequested)
                        this.Close();

                    cancellationTokenSource.Dispose();
                    cancellationTokenSource = null;
                }
            }
        }