/// <summary>
        /// Click event handler for the Open button.  This handles finding and opening the XSD file and the CONFIG file.
        /// Will always prompt for CONFIG and only prompts for XSD if it cannot locate it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenFile_Click(object sender, EventArgs e)
        {
            LoadingLabel.Visible = true;
            var schemaProcessor = new SchemaProcessor();
            DataFile.Instance.SchemaFile = schemaProcessor.ProcessSchema(FilePaths.Instance.SchemaFile);

            if (DataFile.Instance.SchemaFile != null)
            {
                SchemaPath = FilePaths.Instance.SchemaFile;
            }
            else
            {
                var openFile = new OpenFileDialog();
                openFile.Title = "Select the newrelic.xsd file";
                openFile.InitialDirectory = "c:\\ProgramData\\New Relic\\.Net Agent";
                openFile.FileName = "newrelic.xsd";
                openFile.Filter = "xsd files (*.xsd)|*.xsd|All files (*.*)|*.*";
                openFile.FilterIndex = 0;
                openFile.Multiselect = false;
                openFile.RestoreDirectory = true;

                if (openFile.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        DataFile.Instance.SchemaFile = schemaProcessor.ProcessSchema(openFile.FileName);
                        SchemaPath = openFile.FileName;
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                    }
                }
                else
                {
                    TryExportSchema(schemaProcessor);
                }
            }

            if (DataFile.Instance.SchemaFile != null)
            {
                var openFile = new OpenFileDialog();
                openFile.Title = "Select the newrelic.config file";
                openFile.InitialDirectory = Path.GetDirectoryName(FilePaths.Instance.ConfigFile);
                openFile.FileName = "newrelic.config";
                openFile.Filter = "config files (*.config)|*.config|All files (*.*)|*.*";
                openFile.FilterIndex = 0;
                openFile.Multiselect = false;
                openFile.RestoreDirectory = true;

                if (openFile.ShowDialog() == DialogResult.OK)
                {

                    try
                    {
                        var configProcessor = new ConfigProcessor();
                        DataFile.Instance.ConfigFile = configProcessor.ProcessConfig(openFile.FileName);
                        ConfigPath = openFile.FileName;
                        DataFile.Instance.MergedFile = DataFile.Instance.SchemaFile.Clone();
                        var mergeProcessor = new MergeProcessor();
                        mergeProcessor.PrePopulateMergedFile(DataFile.Instance.SchemaFile, DataFile.Instance.MergedFile);
                        mergeProcessor.Merge(DataFile.Instance.ConfigFile);
                        mergeProcessor.SetMergedRootObject(DataFile.Instance.MergedFile);
                        LoadUI();
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                    }
                }
                else
                {
                    TryExportConfig();
                }
            }
            LoadingLabel.Visible = false;
        }
        private void TryExportSchema(SchemaProcessor schemaProcessor)
        {
            try
            {
                if (DialogResult.Yes ==
                    MessageBox.Show("Do you want to use the built in newrelic.xsd file?", "Use built in newrelic.xsd?",
                        MessageBoxButtons.YesNo))
                {
                    using (
                        var resource =
                            Assembly.GetExecutingAssembly()
                                .GetManifestResourceStream("NewRelic.AgentConfiguration.Resources.newrelic.xsd"))
                    {
                        using (
                            var file = new FileStream(Application.StartupPath + "\\newrelic.xsd", FileMode.Create,
                                FileAccess.Write))
                        {
                            resource.CopyTo(file);
                        }
                    }

                    schemaProcessor.ProcessSchema(Application.StartupPath + "\\newrelic.xsd");
                    SchemaPath = Application.StartupPath + "\\newrelic.xsd";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
            }
        }
 public void PopulateSchemaFile()
 {
     var sproc = new SchemaProcessor();
     DataFile.Instance.SchemaFile = sproc.ProcessSchema(PathRoot);
 }