01/21
NameValueCollection:
App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="STSectionGroup">
<section name="STDocumentColumns" type="System.Configuration.NameValueSectionHandler" />
<section name="STDocumentClasses" type="System.Configuration.NameValueSectionHandler" />
</sectionGroup>
</configSections>
<STSectionGroup>
<STDocumentColumns>
<add key="tdm_class.CLASS_NAME" value=""/>
<add key="tn_documentation.cn_part_number" value=""/>
<add key="tn_documentation.tdm_description" value=""/>
<add key="tn_documentation.revision" value=""/>
<add key="tn_documentation.TDM_ID" value=""/>
<add key="tn_documentation.FILE_NAME" value=""/>
<add key="tn_documentation.MODIFICATION_DATE" value=""/>
</STDocumentColumns>
<STDocumentClasses>
<add key="CATIA Drawing" value=""/>
<add key="CATIA Part" value=""/>
<add key="CATIA Product" value=""/>
<add key="CATIA Representation" value=""/>
<add key="TICO CATIA Drawing" value=""/>
<add key="TICO CATIA Part" value=""/>
<add key="TICO CATIA Product" value=""/>
<add key="TICO CATIA cgr" value=""/>
<add key="CAD Document" value=""/>
<add key="TIFF" value=""/>
<add key="TICO TIFF" value=""/>
<add key="TICO IN" value=""/>
<add key="TMHC Document" value=""/>
<add key="TSDR Report" value=""/>
<add key="DE Document" value=""/>
<add key="TMHC ECI" value=""/>
</STDocumentClasses>
</STSectionGroup>
…
</configuration>
Code:
NameValueCollection columncollection = ConfigurationManager.GetSection("STSectionGroup/STDocumentColumns") as NameValueCollection;
StringBuilder builder = new StringBuilder(1000);
builder.Append("Select ");
for (int i = 0; i < columncollection.Count; i++)
{
if (i != columncollection.Count - 1)
{
builder.Append(string.Format("{0},", columncollection.Keys[i]));
}
else
{
builder.Append(columncollection.Keys[i]);
}
}
0 Comments:
Post a Comment
<< Home