Skip to content

Commit

Permalink
Make config non-ReadOnly, with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
claco committed Nov 27, 2008
1 parent 7d82c62 commit 1a9808b
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 32 deletions.
55 changes: 42 additions & 13 deletions Siphon/Configuration/IntervalElement.vb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,46 @@
Public Class IntervalElement
Inherits ConfigurationElement

''' <summary>
''' Gets the value of the interval.
''' </summary>
''' <value></value>
''' <returns>TimeSpan</returns>
''' <remarks></remarks>
<ConfigurationProperty("value", DefaultValue:="00:01:00", IsRequired:=True, IsKey:=True)> _
<TimeSpanValidator(MinValueString:="0")> _
Public Overridable ReadOnly Property Value() As TimeSpan
Get
Return Me.Item("value")
End Get
End Property
''' <summary>
''' Creates a new interval element.
''' </summary>
''' <remarks></remarks>
Public Sub New()

End Sub

''' <summary>
''' Creates a new interval element.
''' </summary>
''' <param name="value">TimeSpan. The value of the new element.</param>
''' <remarks></remarks>
Public Sub New(ByVal value As TimeSpan)
Me.Value = value
End Sub

''' <summary>
''' Gets/set the value of the interval.
''' </summary>
''' <value></value>
''' <returns>TimeSpan</returns>
''' <remarks></remarks>
<ConfigurationProperty("value", DefaultValue:="00:01:00", IsRequired:=True, IsKey:=True)> _
<TimeSpanValidator(MinValueString:="0")> _
Public Overridable Property Value() As TimeSpan
Get
Return Me.Item("value")
End Get
Set(ByVal value As TimeSpan)
Me.Item("value") = value
End Set
End Property

''' <summary>
''' Determins if the config is read only.
''' </summary>
''' <returns>Boolean. Always returns False.</returns>
''' <remarks></remarks>
Public Overrides Function IsReadOnly() As Boolean
Return False
End Function
End Class
65 changes: 57 additions & 8 deletions Siphon/Configuration/MonitorElement.vb
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,95 @@ Public Class MonitorElement
Inherits ConfigurationElement

''' <summary>
''' Gets the name of the current monitor.
''' Creates a new monitor element.
''' </summary>
''' <remarks></remarks>
Public Sub New()

End Sub

''' <summary>
''' Creates a new monitor element.
''' </summary>
''' <param name="name">String. The name of the new monitor.</param>
''' <remarks></remarks>
Public Sub New(ByVal name As String)
Me.Name = name
End Sub

''' <summary>
''' Creates a new monitor element.
''' </summary>
''' <param name="name">String. The name of the new monitor.</param>
''' <param name="type">String. The type of the new monitor.</param>
''' <remarks></remarks>
Public Sub New(ByVal name As String, ByVal type As String)
Me.Name = name
Me.Type = type
End Sub

''' <summary>
''' Gets/sets the name of the current monitor.
''' </summary>
''' <value></value>
''' <returns>String</returns>
''' <remarks></remarks>
<ConfigurationProperty("name", IsKey:=True, IsRequired:=True)> _
Public Overridable ReadOnly Property Name() As String
Public Overridable Property Name() As String
Get
Return Me.Item("name")
End Get
Set(ByVal value As String)
Me.Item("name") = value.Trim
End Set
End Property

''' <summary>
''' Gets the type of the monitor to load.
''' Gets/sets the type of the monitor to load.
''' </summary>
''' <value></value>
''' <returns>String</returns>
''' <remarks></remarks>
<ConfigurationProperty("type", IsRequired:=True)> _
Public Overridable ReadOnly Property Type() As String
Public Overridable Property Type() As String
Get
Return Me.Item("type")
End Get
Set(ByVal value As String)
Me.Item("type") = value.Trim
End Set
End Property

''' <summary>
''' Gets the schedule to use for the current monitor.
''' Gets/sets the schedule to use for the current monitor.
''' </summary>
''' <value></value>
''' <returns>ScheduleElement</returns>
''' <remarks></remarks>
<ConfigurationProperty("schedule", IsRequired:=True)> _
Public Overridable ReadOnly Property Schedule() As ScheduleElement
Public Overridable Property Schedule() As ScheduleElement
Get
Return Me.Item("schedule")
End Get
Set(ByVal value As ScheduleElement)
Me.Item("schedule") = value
End Set
End Property

''' <summary>
''' Gets the processor to use for the current monitor.
''' Gets/sets the processor to use for the current monitor.
''' </summary>
''' <value></value>
''' <returns>ProcessorElement</returns>
''' <remarks></remarks>
<ConfigurationProperty("processor", IsRequired:=True)> _
Public Overridable ReadOnly Property Processor() As ProcessorElement
Public Overridable Property Processor() As ProcessorElement
Get
Return Me.Item("processor")
End Get
Set(ByVal value As ProcessorElement)
Me.Item("processor") = value
End Set
End Property

''' <summary>
Expand All @@ -83,4 +123,13 @@ Public Class MonitorElement

Return monitor
End Function

''' <summary>
''' Determins if the config is read only.
''' </summary>
''' <returns>Boolean. Always returns False.</returns>
''' <remarks></remarks>
Public Overrides Function IsReadOnly() As Boolean
Return False
End Function
End Class
18 changes: 18 additions & 0 deletions Siphon/Configuration/MonitorElementCollection.vb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
Public Class MonitorElementCollection
Inherits ConfigurationElementCollection

''' <summary>
''' Adds a new monitor element.
''' </summary>
''' <param name="monitor">MonitorElement. The new mlonitor being added.</param>
''' <remarks></remarks>
Public Sub Add(ByVal monitor As MonitorElement)
Me.BaseAdd(monitor)
End Sub

''' <summary>
''' Gets a monitor element by index.
''' </summary>
Expand Down Expand Up @@ -52,4 +61,13 @@ Public Class MonitorElementCollection
Protected Overrides Function GetElementKey(ByVal element As System.Configuration.ConfigurationElement) As Object
Return DirectCast(element, MonitorElement).Name
End Function

''' <summary>
''' Determins if the config is read only.
''' </summary>
''' <returns>Boolean. Always returns False.</returns>
''' <remarks></remarks>
Public Overrides Function IsReadOnly() As Boolean
Return False
End Function
End Class
33 changes: 31 additions & 2 deletions Siphon/Configuration/ProcessorElement.vb
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,36 @@ Public Class ProcessorElement
Inherits ConfigurationElement

''' <summary>
''' Gets the type of the processor to load.
''' Creates a new processor element.
''' </summary>
''' <remarks></remarks>
Public Sub New()

End Sub

''' <summary>
''' Creates a new processor element.
''' </summary>
''' <param name="type">String. The type of the new monitor.</param>
''' <remarks></remarks>
Public Sub New(ByVal type As String)
Me.Type = type
End Sub

''' <summary>
''' Gets/sets the type of the processor to load.
''' </summary>
''' <value></value>
''' <returns>String</returns>
''' <remarks></remarks>
<ConfigurationProperty("type", IsRequired:=True)> _
Public Overridable ReadOnly Property Type() As String
Public Overridable Property Type() As String
Get
Return Me.Item("type")
End Get
Set(ByVal value As String)
Me.Item("type") = value.Trim
End Set
End Property

''' <summary>
Expand All @@ -46,4 +66,13 @@ Public Class ProcessorElement

Return processor
End Function

''' <summary>
''' Determins if the config is read only.
''' </summary>
''' <returns>Boolean. Always returns False.</returns>
''' <remarks></remarks>
Public Overrides Function IsReadOnly() As Boolean
Return False
End Function
End Class
23 changes: 19 additions & 4 deletions Siphon/Configuration/ScheduleElement.vb
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,35 @@ Public Class ScheduleElement
Inherits ConfigurationElement

''' <summary>
''' Gets the type of the schedule to load.
''' Gets/sets the type of the schedule to load.
''' </summary>
''' <value></value>
''' <returns>String</returns>
''' <remarks></remarks>
<ConfigurationProperty("type", IsRequired:=True)> _
Public Overridable ReadOnly Property Type() As String
Public Overridable Property Type() As String
Get
Return Me.Item("type")
End Get
Set(ByVal value As String)
Me.Item("type") = value.Trim
End Set
End Property

''' <summary>
''' Gets the interval for use by a schedule.
''' Gets/sets the interval for use by a schedule.
''' </summary>
''' <value></value>
''' <returns>TimeSpan</returns>
''' <remarks></remarks>
<ConfigurationProperty("interval")> _
Public Overridable ReadOnly Property Interval() As IntervalElement
Public Overridable Property Interval() As IntervalElement
Get
Return Me.Item("interval")
End Get
Set(ByVal value As IntervalElement)
Me.Item("interval") = value
End Set
End Property

''' <summary>
Expand Down Expand Up @@ -73,4 +79,13 @@ Public Class ScheduleElement

Return schedule
End Function

''' <summary>
''' Determins if the config is read only.
''' </summary>
''' <returns>Boolean. Always returns False.</returns>
''' <remarks></remarks>
Public Overrides Function IsReadOnly() As Boolean
Return False
End Function
End Class
1 change: 0 additions & 1 deletion Siphon/Configuration/SiphonConfigurationSection.vb
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ Public Class SiphonConfigurationSection

Return assembly.CreateInstance(types(0).Trim, False, BindingFlags.CreateInstance Or BindingFlags.Static Or BindingFlags.Public Or BindingFlags.NonPublic, Nothing, Nothing, Nothing, Nothing)
End Function

End Class
33 changes: 31 additions & 2 deletions Siphon/Configuration/TimeElement.vb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,45 @@ Public Class TimeElement
Inherits ConfigurationElement

''' <summary>
''' Gets the value of the current time of day element.
''' Creates a new time element.
''' </summary>
''' <remarks></remarks>
Public Sub New()

End Sub

''' <summary>
''' Creates a new time element.
''' </summary>
''' <param name="value">TimeSpan. The value of the new element.</param>
''' <remarks></remarks>
Public Sub New(ByVal value As TimeSpan)
Me.Value = value
End Sub

''' <summary>
''' Gets/sets the value of the current time of day element.
''' </summary>
''' <value></value>
''' <returns>TimeSpan</returns>
''' <remarks></remarks>
<ConfigurationProperty("value", DefaultValue:="00:00:00", IsRequired:=True, IsKey:=True)> _
<TimeSpanValidator(MinValueString:="00:00:00", MaxValueString:="23:59:59")> _
Public Overridable ReadOnly Property Value() As TimeSpan
Public Overridable Property Value() As TimeSpan
Get
Return Me.Item("value")
End Get
Set(ByVal value As TimeSpan)
Me.Item("value") = value
End Set
End Property

''' <summary>
''' Determins if the config is read only.
''' </summary>
''' <returns>Boolean. Always returns False.</returns>
''' <remarks></remarks>
Public Overrides Function IsReadOnly() As Boolean
Return False
End Function
End Class

0 comments on commit 1a9808b

Please sign in to comment.