Skip to content

CtcApi.Config

Shawn (work acct) edited this page Jun 8, 2013 · 2 revisions

The CtcApi makes extensive use of custom configuration support in the .NET Framework to provide flexibility in meeting the needs of each college. The classes in this namespace are intended to facilitate the creation and use of such configurations in both the API and your own code.

Examples

CtcConfigBase

This class provides a base of common functionality for constructing custom configuration classes in your code.

 [XmlType("myConfig")]
 public class MyConfig : CtcConfigBase<MyConfig>
 {
   [XmlAttribute("copyright");
   public string Copyright {get;set}
 }

 public class MyClass
 {
   MyClass()
   {
     MyConfig _config = MyConfig.Load();
     string copyrightStatement = _config.Copyright;
   }
 }

NOTE: An IConfigurationSectionHandler class is still required - to perform mapping from the XML to your configuration class.

The Web.config/App.config contents for the code sample above would look something like the following:

 <configuration>
   <configSections>
     <section name="myConfig" type="MyConfigNamespace.MyConfigHandler, AssemblyFileName" />
   </configSections>
   ...
   <myConfig copyright="(c) Bellevue College">
   </myConfig>
   ...
 </configuration>