<?xml version="1.0" encoding="utf-8" ?><
configuration><
configSections><
section name="ParserConfig" type="BMOEnhanced.Plugins.ParserConfigSection, BMOEnhanced.Plugins.PluginSSIS" allowLocation="true" allowDefinition="Everywhere" /></
configSections><
appSettings></appSettings><
ParserConfig Title="BMO Enhanced plugin using SSIS"><
Parsers><
Parser Name="CorpDB_SecY" Pattern="IMATCH_DSECY\d{8}\.txt" Package="\\Imatbccwdvapp04\avtl\CSParsers\config\CorpDB_SECY.dtsx"><
Parameters><!--
<Parameter Name="User::LogName" Value="log.txt"/>--><!--
<Parameter Name="User::ProcessDate" Value="2012-07-01"/>--></
Parameters></
Parser><!--
<Parser Name="CorpDB_SecY" Pattern="IMATCH_DSECY\d{8}\.txt" Package= ""> </Parser>--><
Parser Name="21" Pattern="22" Package="23"></Parser></
Parsers></
ParserConfig></
configuration>
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Configuration;using System.Xml;namespace BMOEnhanced.Plugins{
public class ParserConfigSection : ConfigurationSection{
public ParserConfigSection(){
}
[
ConfigurationProperty("Title", DefaultValue = "",IsRequired =
false, IsKey = false)]
public string Title{
get { return (string)this["Title"]; }
set { this["Title"] = value; }}
[
ConfigurationProperty("Parsers")]
public ParserCollection Parsers{
get { return (ParserCollection)this["Parsers"]; }
set { this["Parsers"] = value; }}
}
[
ConfigurationCollection(typeof(ParserElement), AddItemName = "Parser", ClearItemsName = "clear", RemoveItemName = "remove", CollectionType =
ConfigurationElementCollectionType.BasicMap)]
public class ParserCollection : ConfigurationElementCollection{
protected override ConfigurationElement CreateNewElement() { return new ParserElement(); }
protected override object GetElementKey(ConfigurationElement element) { return (element as ParserElement); }
public ParserElement this[int index]{
get { return (ParserElement)BaseGet(index); }
set{
if (BaseGet(index) != null){
BaseRemoveAt(index);
}
BaseAdd(index,
value);}
}
}
public class ParserElement : ConfigurationElement{
[ConfigurationProperty("Name", DefaultValue = "")]
public string Name{
get { return (String)this["Name"]; }
set { this["Name"] = value; }}
[
ConfigurationProperty("Pattern", IsRequired = true)]
public string Pattern{
get { return (String)this["Pattern"]; }
set { this["Pattern"] = value; }}
[
ConfigurationProperty("Package", IsRequired = true)]
public string Package{
get { return (String)this["Package"]; }
set { this["Package"] = value; }}
[
ConfigurationProperty("Parameters")]
public ParameterCollection Parameters{
get { return (ParameterCollection)this["Parameters"]; }
set { this["Parameters"] = value; }}
}
[
ConfigurationCollection(typeof(ParameterElement), AddItemName = "Parameter",CollectionType =
ConfigurationElementCollectionType.BasicMap)]
public class ParameterCollection : ConfigurationElementCollection{
protected override ConfigurationElement CreateNewElement() { return new ParameterElement(); }
protected override object GetElementKey(ConfigurationElement element) { return (element as ParameterElement) ; }
public ParameterElement this[int index] { get { return (ParameterElement)BaseGet(index); } }}
public class ParameterElement : ConfigurationElement{
[ConfigurationProperty("Name", DefaultValue = "InputFile")]
public string Name{
get { return (String)this["Name"]; }
set { this["Name"] = value; }}
[
ConfigurationProperty("Value", DefaultValue = "")]
public string Value{
get { return (String)this["Value"]; }
set { this["Value"] = value; }}
}
public class GenericConfigurationElementCollection<T> : ConfigurationElementCollection, IEnumerable<T> where T : ConfigurationElement, new(){
List<T> _elements = new List<T>();
protected override ConfigurationElement CreateNewElement(){
T newElement =
new T();_elements.Add(newElement);
return newElement;}
protected override object GetElementKey(ConfigurationElement element){
return _elements.Find(e => e.Equals(element));}
public new IEnumerator<T> GetEnumerator(){
return _elements.GetEnumerator();}
}
//IConfigurationSectionHandler deprecated ??//public class ParserConfigSection : IConfigurationSectionHandler//{// private List<ParserElement> Parsers=new List<ParserElement>();// public ParserConfigSection()// {// }// public object Create(object parent, object configContext, XmlNode section)// {// Parsers.Clear();// foreach (XmlNode node in section.ChildNodes)// {// ParserElement parser = new ParserElement();// parser.Name = node.Attributes["Name"].Value;// parser.Name = node.Attributes["Pattern"].Value;// parser.Name = node.Attributes["Package"].Value; // }// return Parsers;// }//}}