Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a simple example.</p> <pre><code>//START CODE //MyCompany.MyProject.csproj which results in MyCompany.MyProject.dll //Add a Folder called "Configuration" namespace MyCompany.MyProject.Configuration { using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Configuration; public class TransformationToDirectoryMapping : ConfigurationElement { private const string FRIENDLY_NAME = "FriendlyName"; private const string PICKUP_FOLDER = "PickupFolder"; [ConfigurationProperty(FRIENDLY_NAME, DefaultValue = "", IsKey = false, IsRequired = true)] public string FriendlyName { get { return ((string)(base[FRIENDLY_NAME])); } set { base[FRIENDLY_NAME] = value; } } [ConfigurationProperty(PICKUP_FOLDER, DefaultValue = "", IsKey = true, IsRequired = true)] public string PickupFolder { get { return ((string)(base[PICKUP_FOLDER])); } set { base[PICKUP_FOLDER] = value; } } } //----------------------------------------------------------------------- //----------------------------------------------------------------------- [ConfigurationCollection(typeof(TransformationToDirectoryMapping))] public class TransformationToDirectoryMappingCollection : ConfigurationElementCollection { protected override ConfigurationElement CreateNewElement() { return new TransformationToDirectoryMapping(); } protected override object GetElementKey(ConfigurationElement element) { return ((TransformationToDirectoryMapping)(element)).PickupFolder; } public TransformationToDirectoryMapping this[int idx] { get { return (TransformationToDirectoryMapping)BaseGet(idx); } } new public TransformationToDirectoryMapping this[string key] { get { return (TransformationToDirectoryMapping)BaseGet(key); } } } //----------------------------------------------------------------------- //----------------------------------------------------------------------- public class TransformationToDirectoryMappingConfigSection : ConfigurationSection { private const string TRANSFORMATION_TO_DIRECTORY_MAPPINGS = "TransformationToDirectoryMappings"; [ConfigurationProperty(TRANSFORMATION_TO_DIRECTORY_MAPPINGS)] public TransformationToDirectoryMappingCollection TransformationToDirectoryMappingItems { get { return ((TransformationToDirectoryMappingCollection)(base[TRANSFORMATION_TO_DIRECTORY_MAPPINGS])); } } } //----------------------------------------------------------------------- //----------------------------------------------------------------------- public static class MyRetriever { public const string MAPPINGS_CONFIGURATION_SECTION_NAME = "TransformationToDirectoryMappingsSection"; public static TransformationToDirectoryMappingCollection GetTheCollection() { TransformationToDirectoryMappingConfigSection mappingsSection = (TransformationToDirectoryMappingConfigSection)ConfigurationManager.GetSection(MAPPINGS_CONFIGURATION_SECTION_NAME); if (mappingsSection != null) { return mappingsSection.TransformationToDirectoryMappingItems; } return null; // OOPS! } } } </code></pre> <p>//XML for config file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;configSections&gt; &lt;section name="TransformationToDirectoryMappingsSection" type="MyCompany.MyProject.Configuration.TransformationToDirectoryMappingConfigSection, MyCompany.MyProject"/&gt; &lt;/configSections&gt; &lt;TransformationToDirectoryMappingsSection&gt; &lt;TransformationToDirectoryMappings&gt; &lt;add FriendlyName="Hello" PickupFolder="C:\WUWUTemp\pickups\pickup11\" /&gt; &lt;add FriendlyName="GoodBye" PickupFolder="C:\WUWUTemp\pickups\pickup12\" /&gt; &lt;/TransformationToDirectoryMappings&gt; &lt;/TransformationToDirectoryMappingsSection&gt; &lt;/configuration&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload