|
using System;
using System.Configuration;
using System.Collections;
using System.Xml;
namespace Params
{
public class ParamConfigurationSectionHandler : IConfigurationSectionHandler
{
#region IConfigurationSectionHandler Members
public object Create(object parent, object context, System.Xml.XmlNode section)
{
if(ParamCollection.ApplicationParameters != null)
throw(new Exception("ParamCollection already initialized. Use ParamCollection.ApplicationParameters."));
ParamCollection col = new ParamCollection();
col.DefaultAllowMultipleValues = Helper.GetBool(section.Attributes, "defaultAllowMultiple", false);
col.DefaultIsOptional = Helper.GetBool(section.Attributes, "defaultOptional", false);
col.DefaultType = (ParamType)Helper.GetEnum(section.Attributes, "defaultType", ParamType.String, typeof(ParamType));
col.ShortControlString = Helper.GetString(section.Attributes, "shortControlString", "-");
col.LongControlString = Helper.GetString(section.Attributes, "longControlString", "-");
col.SeparatorChar = Helper.GetString(section.Attributes, "separatorChar", " ")[0];
col.AttribChars = Helper.GetString(section.Attributes, "attribChars", " ").ToCharArray();
col.AutoGenerateParams = Helper.GetBool(section.Attributes, "autoGenerateParams", false);
foreach(XmlNode param in section.ChildNodes)
{
if(param.NodeType == XmlNodeType.Element && param.Name.ToLower() == "param")
{
col.Add(new Param(param, col));
}
}
return col;
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Just you average programmer geek from Romania. Student at Faculty of Computer Science, Al. I. Cuza University Iasi, Romania.