我想建立這樣配置元素集合節
<logSectionGroup>
<logSection name="Testttt">
<properties name ="Pride">
<pathName="TestingLog.txt"/>
<deleteRetention="100"/>
<deleteZeroRetention="5"/>
<wildcard="*.txt"/>
</properties>
<properties name ="Adhoc">
<pathName="blah.txt"/>
<deleteRetention="70"/>
<deleteZeroRetention="3"/>
<wildcard="*.*"/>
</properties>
</logSection>
</logSectionGroup>
一個自定義應用程序的配置元素集合節這可能嗎?屬性將是配置元素,而日誌部分將是配置元素集合。問題是,我只看到你可以擁有多個元素的多個實例,而不是多個元素。
<Section name="Section1">
<Section name="Section1">
<SubSection name="SubSection1">
<Item name="Item1" />
<Item name="Item2" />
</SubSection>
<SubSection name="SubSection2">
<Item name="Item1" />
<Item name="Item2" />
</SubSection>
</Section>
當您使用GetElementKey()你擁有了它在上面的例子中歸元「名」,但你會如何返回4個不同的元素,如「路徑名」「deleteRetention」等
這裏是我的定義對於PropElement
Public Class PropElement
Inherits ConfigurationElement
<ConfigurationProperty("pathName", IsRequired:=True)> _
Public Property PathName() As String
Get
Return CStr(Me("pathName"))
End Get
Set(ByVal value As String)
Me("pathName") = value
End Set
End Property
<ConfigurationProperty("deleteRetention", DefaultValue:="0", IsRequired:=False)> _
Public Property DeleteRetention() As Integer
Get
Return CStr(Me("deleteRetention"))
End Get
Set(ByVal value As Integer)
Me("deleteRetention") = value
End Set
End Property
<ConfigurationProperty("deleteZeroRetention", DefaultValue:="0", IsRequired:=False)> _
Public Property DeleteZeroRetention() As Integer
Get
Return CStr(Me("deleteZeroRetention"))
End Get
Set(ByVal value As Integer)
Me("deleteZeroRetention") = value
End Set
End Property
<ConfigurationProperty("wildcard", DefaultValue:="*.*", IsRequired:=False)> _
Public Property Wildcard() As String
Get
Return CStr(Me("wildcard"))
End Get
Set(ByVal value As String)
Me("wildcard") = value
End Set
End Property
末級
你能再詳細一點嗎?我已經爲PropElements添加了我的代碼。我不確定你收集的密鑰是什麼意思等。 謝謝 – Matt 2010-08-24 16:49:04