Exemple #1
0
        private ClientConfiguration GetClientConfiguration()
        {
            XDocument document = null;

            try {
                document = XDocument.Parse(txtConfiguration.Text);
            } catch (Exception e) {
                MessageBox.Show(this, string.Format("Failed loading configuration from editor as XML document:{0}{0}{1}", Environment.NewLine, e.Message), "Error ...", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            string[] messages;
            if (ClientConfiguration.Validate(document, out messages))
            {
                return(ClientConfiguration.FromSerializedXml(txtConfiguration.Text));
            }
            else
            {
                MessageBox.Show(this, string.Format("Validation of configuration failed:{0}{0}{1}", Environment.NewLine, string.Join("  - ", messages)), "Error ...", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
        }