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>