2
我想在我的定制配置部分中使用枚举。所以我实现了一个枚举DatabaseMode和相应的属性。定制配置部分中的Enum IntellisSense
我还在我的System.Configuration.ConfigurationElement
中实施了相应的Property。但是为了使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; }
}
下面我schema文件的重要组成部分:
<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>