AP&C API Reference
Public Member Functions | Protected Member Functions | Properties | List of all members
Apac.Configuration.XmlSerializingConfigSection Class Reference

A configuration section for containing an arbitrary serialized object. This implementation allows for redirection to an external configuration file. More...

Inheritance diagram for Apac.Configuration.XmlSerializingConfigSection:

Public Member Functions

 XmlSerializingConfigSection ()
 Create an instance of this object. More...
 

Protected Member Functions

override object GetRuntimeObject ()
 Retrieves the contained object from the section. More...
 
override void DeserializeSection (System.Xml.XmlReader reader)
 Deserializes the configuration section in the configuration file. More...
 
override void DeserializeElement (XmlReader reader, bool serializeCollectionKey)
 Deserializes the configuration element in the configuration file. More...
 
override string SerializeSection (ConfigurationElement parentElement, string name, ConfigurationSaveMode saveMode)
 Serializes the configuration section to an XML string representation. More...
 
override bool SerializeToXmlElement (XmlWriter writer, string elementName)
 Serializes the section into the configuration file, possibly writing to the external file as well, if FileName is specified. </summary

Parameters
writerThe writer to use for serializing the class.</param
Parameters
elementNameThe name of the configuration section.</param
Returns
True if successful, false otherwise.

 
override bool SerializeElement (XmlWriter writer, bool serializeCollectionKey)
 Serilize the element to XML. More...
 

Properties

string FileName [get, set]
 The name of an external file containing the serialized object. More...
 
string TypeName [get]
 The name of the type that is serialized. More...
 
object Data [get, set]
 The contained object. More...
 

Detailed Description

A configuration section for containing an arbitrary serialized object. This implementation allows for redirection to an external configuration file.

This feature is instrumental in making management of configuration for different environments easy. Keep all configs for all environments and switch between them by switching the file name in the main configuration file.

Adapted from Jon Wojtowicz's solution: http://www.eggheadcafe.com/articles/20060622.asp. Changes include some static helper methods for getting configuration sections, moved strings to resources, some other code cleanup, and a few changes for style.

Constructor & Destructor Documentation

◆ XmlSerializingConfigSection()

Apac.Configuration.XmlSerializingConfigSection.XmlSerializingConfigSection ( )
inline

Create an instance of this object.

Member Function Documentation

◆ DeserializeElement()

override void Apac.Configuration.XmlSerializingConfigSection.DeserializeElement ( XmlReader  reader,
bool  serializeCollectionKey 
)
inlineprotected

Deserializes the configuration element in the configuration file.

Parameters
readerThe reader containing the XML for the section.
serializeCollectionKeytrue to serialize only the collection key properties; otherwise, false. Ignored in this implementation.

◆ DeserializeSection()

override void Apac.Configuration.XmlSerializingConfigSection.DeserializeSection ( System.Xml.XmlReader  reader)
inlineprotected

Deserializes the configuration section in the configuration file.

Parameters
readerThe reader containing the XML for the section.

◆ GetRuntimeObject()

override object Apac.Configuration.XmlSerializingConfigSection.GetRuntimeObject ( )
inlineprotected

Retrieves the contained object from the section.

Returns
The contained data object.

◆ SerializeElement()

override bool Apac.Configuration.XmlSerializingConfigSection.SerializeElement ( XmlWriter  writer,
bool  serializeCollectionKey 
)
inlineprotected

Serilize the element to XML.

Parameters
writerThe XmlWriter to use for the serialization.
serializeCollectionKeyFlag whether to serialize the collection keys. Not used in this override.
Returns
True if the serialization was successful, false otherwise.

◆ SerializeSection()

override string Apac.Configuration.XmlSerializingConfigSection.SerializeSection ( ConfigurationElement  parentElement,
string  name,
ConfigurationSaveMode  saveMode 
)
inlineprotected

Serializes the configuration section to an XML string representation.

Parameters
parentElementThe parent element of this element.
nameThe name of the section.
saveModeThe mode to use for saving.
Returns
The string representation of the section.

Property Documentation

◆ Data

object Apac.Configuration.XmlSerializingConfigSection.Data
getset

The contained object.

◆ FileName

string Apac.Configuration.XmlSerializingConfigSection.FileName
getset

The name of an external file containing the serialized object.

◆ TypeName

string Apac.Configuration.XmlSerializingConfigSection.TypeName
get

The name of the type that is serialized.


The documentation for this class was generated from the following file: