【发布时间】:2011-04-12 18:12:15
【问题描述】:
我想在我的自定义配置部分中使用枚举。所以我实现了一个枚举 DatabaseMode 和相应的属性。
我还在我的System.Configuration.ConfigurationElement 中实现了相应的属性。但要让 IntelliSense 在 web.config 中工作,我需要提供架构定义 (xsd),以 xsd 格式镜像相同的结构。
我的问题是架构应该如何支持枚举?
具有不同选项的枚举:
public enum DatabaseMode
{
Development,
Deployment,
Production
}
存储模式信息的属性:
[ConfigurationProperty(databaseAlias)]
public DatabaseElement Database
{
get { return (DatabaseElement)this[databaseAlias]; }
set { this[databaseAlias] = value; }
}
在我的架构文件的重要部分下方:
<xs:element name="database">
<xs:complexType>
<xs:attribute name="server" type="xs:anyURI" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="user" type="xs:string" use="required" />
<xs:attribute name="password" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
【问题讨论】:
标签: asp.net enums schema intellisense