c# - Add a new collection inside a custom configuration section -


i have custom configuration section , need add new namevalue thing it

here hierarchy

 -organizationconfigurations  |-organizationconfigselector  |-specificconfigurations   |-organizationconfig 

now need add element called skiplanguages organizationconfig , simple collection element going hold strings. here xml sample

<?xml version="1.0" encoding="utf-8" ?> 

<matcher type="host" match="hornet" servicename="config-hornet"/> <matcher type="parameter" match="vtdev" servicename="config-test-server"/> 

<organizationconfig name="config-hornet">   <add name="organization_identifier" value="sampleorg"/>    <add name="allow_selfregistration" value="true"/>    <add name="applicationselector" value=""/>   <add name="registrationselector" value=""/>    <add name="enrollpinvalidity" value="00.00:01:00"/>   <add name="enrollincoming" value="0123456789"/>   <add name="enrolloutgoing" value="pin"/>    <add name="enrollmentlockout" value="00.00:01:00"/>   <add name="pinlockout" value="00.00:00:30"/>    <skiplanguages>     <add name="en"/>     <add name="ur-ur" />   </skiplanguages>    <add name="menu_hide_details" value="false"/>   <add name="international_format_example" value="00971559559123"/>    <add name="service_operator_name" value="admin"/>   <add name="service_operator_password" value="admin"/>    <add name="service_operator_address_vtadp" value="https://hornet.org.com:1337/main/basichttp"/>   <add name="service_operator_address_admin" value="https://hornet.org.com:1337/admn/basichttp"/>   <add name="service_operator_address_pwr" value="https://hornet.org.com:1337/pwr/basichttp"/>  </organizationconfig> 

the classes specificconfigurations & organizationconfig & are:

    [configurationcollection(typeof(organizationconfig), additemname = "organizationconfig")]     public class specificconfigurations : configurationelementcollection     {         #region indexer         public organizationconfig this[int index]         {             { return baseget(index) organizationconfig; }             set             {                 if (baseget(index) != null)                 {                     baseremoveat(index);                 }                  baseadd(index, value);             }         }         #endregion          #region public method(s)         public organizationconfig getserviceinfo(string servicename)         {             return baseget(servicename) organizationconfig;         }         #endregion          #region overridden method(s)         protected override configurationelement createnewelement()         {             return new organizationconfig();         }          protected override object getelementkey(configurationelement element)         {             return ((organizationconfig)element).name;         }         #endregion     }      public class organizationconfig : configurationsection     {         #region configuration properties         [configurationproperty("name", isrequired = true)]         public string name         {             { return this["name"] string; }             set { this["name"] = value; }         }          [configurationproperty("", isdefaultcollection = true)]         public namevalueconfigurationcollection settings         {             { return (namevalueconfigurationcollection)base[""]; }         }         #endregion     } 

for time being, added skiplanguages namevalue pair value semi-colon separated string languages hide/block. apparently, worked , accepted lead. so, i'm completing question own answer.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -