Skip to content

Commit 123f6da

Browse files
committed
added overloaded constructor to MonthRange
1 parent 66d05c9 commit 123f6da

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

CompuMaster.Calendar/CompuMaster.Calendar.vbproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<Product>CompuMaster.Calendar</Product>
88
<Copyright>2005-2022 CompuMaster GmbH</Copyright>
99
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10-
<AssemblyVersion>2022.3.22.200</AssemblyVersion>
11-
<Version>2022.3.22.200</Version>
10+
<AssemblyVersion>2022.3.28.100</AssemblyVersion>
11+
<Version>2022.3.28.100</Version>
1212
<VBRuntime>Embed</VBRuntime>
1313
<IsPackable>true</IsPackable>
1414
</PropertyGroup>

CompuMaster.Calendar/MonthRange.vb

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,29 @@ Namespace CompuMaster.Calendar
1010
Implements IComparable
1111

1212
''' <summary>
13-
''' Create a new instance of MonthRange with clones of first and last period (to behave more like value type instead of reference type)
13+
''' Create a new instance of MonthRange with clones of first and last month (to behave more like value type instead of reference type)
1414
''' </summary>
15-
''' <param name="firstPeriod"></param>
16-
''' <param name="lastPeriod"></param>
17-
Public Sub New(firstPeriod As CompuMaster.Calendar.Month, lastPeriod As CompuMaster.Calendar.Month)
18-
If firstPeriod Is Nothing Then Throw New ArgumentNullException(NameOf(firstPeriod))
19-
If lastPeriod Is Nothing Then Throw New ArgumentNullException(NameOf(lastPeriod))
20-
If firstPeriod > lastPeriod Then Throw New ArgumentException("First period must be before last period")
21-
Me._FirstMonth = firstPeriod.Clone
22-
Me._LastMonth = lastPeriod.Clone
15+
''' <param name="firstMonth"></param>
16+
''' <param name="lastMonth"></param>
17+
Public Sub New(firstMonth As CompuMaster.Calendar.Month, lastMonth As CompuMaster.Calendar.Month)
18+
If firstMonth Is Nothing Then Throw New ArgumentNullException(NameOf(firstMonth))
19+
If lastMonth Is Nothing Then Throw New ArgumentNullException(NameOf(lastMonth))
20+
Me._FirstMonth = firstMonth.Clone
21+
Me._LastMonth = lastMonth.Clone
22+
If Me._FirstMonth > Me._LastMonth Then Throw New ArgumentException("First month must be before last month")
23+
End Sub
24+
25+
''' <summary>
26+
''' Create a new instance of MonthRange with clones of first and last month (to behave more like value type instead of reference type)
27+
''' </summary>
28+
''' <param name="startYear"></param>
29+
''' <param name="startMonth"></param>
30+
''' <param name="endYear"></param>
31+
''' <param name="endMonth"></param>
32+
Public Sub New(startYear As Integer, startMonth As Integer, endYear As Integer, endMonth As Integer)
33+
Me._FirstMonth = New Month(startYear, startMonth)
34+
Me._LastMonth = New Month(endYear, endMonth)
35+
If Me._FirstMonth > Me._LastMonth Then Throw New ArgumentException("Start month must be before last month")
2336
End Sub
2437

2538
Private _FirstMonth As CompuMaster.Calendar.Month

0 commit comments

Comments
 (0)