using System.Collections.Generic; using System.Configuration; namespace RiaService.Common { public class RecordServerConfig : ConfigurationSection { [ConfigurationProperty("", IsDefaultCollection = true)] public RecordServerCollection ServerList { get { return (RecordServerCollection)base[""]; } } } [ConfigurationCollection(typeof(RecordServerSection))] public class RecordServerCollection : ConfigurationElementCollection { public override ConfigurationElementCollectionType CollectionType { get { return ConfigurationElementCollectionType.BasicMap; } } protected override string ElementName { get { return "Server"; } } protected override ConfigurationElement CreateNewElement() { return new RecordServerSection(); } protected override object GetElementKey(ConfigurationElement element) { return ((RecordServerSection)element).ServerID; } public List GetServerList() { var enumerater = base.GetEnumerator(); List rsult = new List(); while (enumerater.MoveNext()) { var section = enumerater.Current as RecordServerSection; //if (section != null && section.ServerID == serverid) { rsult.Add(section); } } return rsult; } } public class RecordServerSection : ConfigurationElement { [ConfigurationProperty("ServerID", IsRequired = true, IsKey = true)] public string ServerID { get { return (string)base["ServerID"]; } set { base["ServerID"] = value; } } [ConfigurationProperty("UserName")] public string UserName { get { return (string)base["UserName"]; } set { base["UserName"] = value; } } [ConfigurationProperty("Password")] public string Password { get { return (string)base["Password"]; } set { base["Password"] = value; } } [ConfigurationProperty("Remote")] public string Remote { get { return (string)base["Remote"]; } set { base["Remote"] = value; } } [ConfigurationProperty("From")] public string From { get { return (string)base["From"]; } set { base["From"] = value; } } [ConfigurationProperty("To")] public string To { get { return (string)base["To"]; } set { base["To"] = value; } } } }