Пример #1
0
 private void btDeleteConfigValue_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (this.lsbEndpoints.Items.Count <= 0)
         {
             return;
         }
         MainConfiguration config = MainConfiguration.GetConfig();
         config.DeleteConfigValue(this.tbConfigname.Text);
         int selectedIndex = this.lsbEndpoints.SelectedIndex;
         this.BindConfig();
         if (this.lsbEndpoints.Items.Count >= selectedIndex && this.lsbEndpoints.Items.Count > 0)
         {
             this.lsbEndpoints.SelectedIndex = selectedIndex - 1;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Пример #2
0
 private void BindConfig()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         this.conf      = MainConfiguration.GetConfig();
         if (this.conf == null)
         {
             return;
         }
         this.BindLsbEndPoints(this.conf.ConfigValues);
         ConfigValue configValue = Enumerable.FirstOrDefault <ConfigValue>((IEnumerable <ConfigValue>) this.conf.ConfigValues);
         if (configValue != null)
         {
             this.BindConfig(configValue.ConfigName);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Пример #3
0
 private void btSaveConfig_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(this.txtEndpoint.Text))
         {
             return;
         }
         if (Uri.IsWellFormedUriString(this.txtEndpoint.Text, UriKind.Absolute))
         {
             Cursor.Current = Cursors.WaitCursor;
             var bindingType = this.rbBasicHttpBinding.Checked ? BindingType.BasicHttpBinding : BindingType.WSHttpBinding;
             var config      = MainConfiguration.GetConfig();
             config.SetConfig(this.tbConfigname.Text, this.txtDomain.Text, this.txtUsername.Text, this.txtPassword.Text, new Uri(this.txtEndpoint.Text), bindingType);
             int selectedIndex = this.lsbEndpoints.SelectedIndex;
             BindConfig();
             lsbEndpoints.SelectedIndex = selectedIndex;
         }
         else
         {
             MessageBox.Show("The endpoint uri is not valid!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Пример #4
0
        //private static MainConfiguration GetConfig(StringBuilder XmlConfigurationString)
        //{
        //    try
        //    {
        //        XmlSerializer xmlSerializer = new XmlSerializer(typeof(MainConfiguration));
        //        StringReader stringReader = new StringReader(((object)XmlConfigurationString).ToString());
        //        XmlTextReader xmlTextReader = new XmlTextReader((TextReader)stringReader);
        //        MainConfiguration mainConfiguration = xmlSerializer.Deserialize((XmlReader)xmlTextReader) as MainConfiguration;
        //        xmlTextReader.Close();
        //        stringReader.Close();
        //        return mainConfiguration;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}



        public static List <ConfigValue> GetConfigValues()
        {
            return(MainConfiguration.GetConfig().ConfigValues);
        }