We thought of deserializing XML. We can get this object.
[Serializable ()]
[Xmlroot ("fetcherconfig")]
Public class fetcherconfiguration
{
/** // Some attributes
Public static fetcherconfiguration getconfig ()
{
If (instance _ = NULL)
{
Instance _ = (fetcherconfiguration) configurationsettings. getconfig ("fetcherconfig ");
}
Return instance _;
}
}
Where does the XML information come from? We put it in APP. config, so we need the following handler.
Public class fetcherconfigserializersectionhandler: iconfigurationsectionhandler
{
Iconfigurationsectionhandler members # region iconfigurationsectionhandler members
Public object create (Object parent, object configcontext, system. xml. xmlnode Section)
{
Xmlserializer SER = new xmlserializer (typeof (fetcherconfiguration ));
Return Ser. deserialize (New xmlnodereader (section ));
}
# Endregion
}
Configuration
We need to add our <configsections>
<Section name = "configuration section name xmlroot name" type = "class full name, class library name"/>
Next we can put some information
<Configuration>
You don't know what to put. You can serialize the class you need first. You can simply copy the information.