Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
Some refactorings to be done...
Browse files Browse the repository at this point in the history
  • Loading branch information
AptiviCEO committed Nov 27, 2020
1 parent 1c04e43 commit 6bb1d7a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 60 deletions.
4 changes: 2 additions & 2 deletions Extensification.Tests/Array.vb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Public Class ArrayTests
Public Sub TestAdd()
Dim TargetArray() As Integer = {2, 3}
TargetArray = TargetArray.Add(4)
Assert.IsTrue(TargetArray.Count = 3)
Assert.IsTrue(TargetArray.Length = 3)
End Sub

''' <summary>
Expand All @@ -21,7 +21,7 @@ Public Class ArrayTests
Public Sub TestRemove()
Dim TargetArray() As Integer = {2, 3, 4}
TargetArray = TargetArray.Remove(4)
Assert.IsTrue(TargetArray.Count = 2)
Assert.IsTrue(TargetArray.Length = 2)
End Sub

''' <summary>
Expand Down
8 changes: 4 additions & 4 deletions Extensification.Tests/Dictionary.vb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Public Class DictionaryTests
Public Sub TestCountFullEntries()
Dim TargetDict As New Dictionary(Of String, String) From {{"Full", ""}, {"", "entry"}, {"Index", "5"}}
Dim TargetDictObjects As New Dictionary(Of String, String) From {{"Object 1", 68}, {"Object 2", Nothing}}
Assert.AreEqual(CLng(2), TargetDict.CountFullEntries)
Assert.AreEqual(CLng(1), TargetDictObjects.CountFullEntries)
Assert.AreEqual(2, TargetDict.CountFullEntries)
Assert.AreEqual(1, TargetDictObjects.CountFullEntries)
End Sub

''' <summary>
Expand All @@ -41,8 +41,8 @@ Public Class DictionaryTests
Public Sub TestCountEmptyEntries()
Dim TargetDict As New Dictionary(Of String, String) From {{"Full", ""}, {"", "entry"}, {"Index", "5"}}
Dim TargetDictObjects As New Dictionary(Of String, Object) From {{"Object 1", 68}, {"Object 2", Nothing}}
Assert.AreEqual(CLng(1), TargetDict.CountEmptyEntries)
Assert.AreEqual(CLng(1), TargetDictObjects.CountEmptyEntries)
Assert.AreEqual(1, TargetDict.CountEmptyEntries)
Assert.AreEqual(1, TargetDictObjects.CountEmptyEntries)
End Sub

''' <summary>
Expand Down
8 changes: 4 additions & 4 deletions Extensification.Tests/List.vb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ Public Class ListTests
Public Sub TestCountFullEntries()
Dim TargetList As New List(Of String) From {"Full", "", "", "entry", "", "5"}
Dim TargetListObjects As New List(Of Object) From {12, Nothing, 32, 48}
Assert.AreEqual(CLng(3), TargetList.CountFullEntries)
Assert.AreEqual(CLng(3), TargetListObjects.CountFullEntries)
Assert.AreEqual(3, TargetList.CountFullEntries)
Assert.AreEqual(3, TargetListObjects.CountFullEntries)
End Sub

''' <summary>
Expand All @@ -43,8 +43,8 @@ Public Class ListTests
Public Sub TestCountEmptyEntries()
Dim TargetList As New List(Of String) From {"Full", "", "", "entry", "", "", "6"}
Dim TargetListObjects As New List(Of Object) From {12, Nothing, 32, 48}
Assert.AreEqual(CLng(4), TargetList.CountEmptyEntries)
Assert.AreEqual(CLng(1), TargetListObjects.CountEmptyEntries)
Assert.AreEqual(4, TargetList.CountEmptyEntries)
Assert.AreEqual(1, TargetListObjects.CountEmptyEntries)
End Sub

''' <summary>
Expand Down
16 changes: 8 additions & 8 deletions Extensification/Array.vb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Namespace ArrayExts
''' <returns>An array with added item</returns>
<Extension>
Public Function Add(Of T)(ByVal TargetArray() As T, ByVal Item As T) As T()
If TargetArray Is Nothing Then Throw New ArgumentNullException("TargetArray")
If TargetArray Is Nothing Then Throw New ArgumentNullException(NameOf(TargetArray))
ReDim Preserve TargetArray(TargetArray.Length)
TargetArray(TargetArray.Length - 1) = Item
Return TargetArray
Expand All @@ -27,7 +27,7 @@ Namespace ArrayExts
''' <returns>An array without targeted item</returns>
<Extension>
Public Function Remove(Of T)(ByVal TargetArray() As T, ByVal Item As T) As T()
If TargetArray Is Nothing Then Throw New ArgumentNullException("TargetArray")
If TargetArray Is Nothing Then Throw New ArgumentNullException(NameOf(TargetArray))
Dim TargetArrayList As List(Of T) = TargetArray.ToList
TargetArrayList.Remove(Item)
Return TargetArrayList.ToArray()
Expand All @@ -41,7 +41,7 @@ Namespace ArrayExts
''' <returns>An array list of an array</returns>
<Extension>
Public Function ToArrayList(Of T)(ByVal TargetArray() As T) As ArrayList
If TargetArray Is Nothing Then Throw New ArgumentNullException("TargetArray")
If TargetArray Is Nothing Then Throw New ArgumentNullException(NameOf(TargetArray))
Dim ArrayValues As New ArrayList
ArrayValues.AddRange(TargetArray)
Return ArrayValues
Expand All @@ -56,7 +56,7 @@ Namespace ArrayExts
''' <returns>List of indexes. If none is found, returns an empty array list</returns>
<Extension>
Public Function GetIndexFromEntry(Of T)(ByVal TargetArray() As T, ByVal Entry As T) As Integer()
If TargetArray Is Nothing Then Throw New ArgumentNullException("TargetArray")
If TargetArray Is Nothing Then Throw New ArgumentNullException(NameOf(TargetArray))
Dim Indexes As New ArrayList
For Index As Integer = 0 To TargetArray.Length - 1
Dim ArrayEntry As Object = TargetArray(Index)
Expand All @@ -76,7 +76,7 @@ Namespace ArrayExts
<Extension>
Public Function CountFullEntries(Of T)(TargetArray() As T) As Long
Dim FullEntries As Long
For i As Long = 0 To TargetArray.LongCount - 1
For i As Long = 0 To TargetArray.LongLength - 1
If TargetArray(i) IsNot Nothing Then
If TypeOf TargetArray(i) Is String Then
If Not TargetArray(i).Equals("") Then
Expand All @@ -99,7 +99,7 @@ Namespace ArrayExts
<Extension>
Public Function CountEmptyEntries(Of T)(TargetArray() As T) As Long
Dim EmptyEntries As Long
For i As Long = 0 To TargetArray.LongCount - 1
For i As Long = 0 To TargetArray.LongLength - 1
If TargetArray(i) Is Nothing Then
EmptyEntries += 1
ElseIf TypeOf TargetArray(i) Is String And TargetArray(i).Equals("") Then
Expand All @@ -118,7 +118,7 @@ Namespace ArrayExts
<Extension>
Public Function GetIndexesOfFullEntries(Of T)(TargetArray() As T) As Integer()
Dim FullIndexes As New List(Of Integer)
For i As Long = 0 To TargetArray.LongCount - 1
For i As Long = 0 To TargetArray.LongLength - 1
If TargetArray(i) IsNot Nothing Then
If TypeOf TargetArray(i) Is String Then
If Not TargetArray(i).Equals("") Then
Expand All @@ -141,7 +141,7 @@ Namespace ArrayExts
<Extension>
Public Function GetIndexesOfEmptyEntries(Of T)(TargetArray() As T) As Integer()
Dim EmptyIndexes As New List(Of Integer)
For i As Long = 0 To TargetArray.LongCount - 1
For i As Long = 0 To TargetArray.LongLength - 1
If TargetArray(i) Is Nothing Then
EmptyIndexes.Add(i)
ElseIf TypeOf TargetArray(i) Is String And TargetArray(i).Equals("") Then
Expand Down
4 changes: 2 additions & 2 deletions Extensification/ArrayList.vb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Namespace ArrayListExts
''' <returns>A list from array list</returns>
<Extension>
Public Function ToList(ByVal TargetArray As ArrayList) As List(Of Object)
If TargetArray Is Nothing Then Throw New ArgumentNullException("TargetArray")
If TargetArray Is Nothing Then Throw New ArgumentNullException(NameOf(TargetArray))
Dim ArrayValues As New List(Of Object)
ArrayValues.AddRange(TargetArray.ToArray)
Return ArrayValues
Expand All @@ -24,7 +24,7 @@ Namespace ArrayListExts
''' <returns>List of indexes. If none is found, returns an empty array list</returns>
<Extension>
Public Function GetIndexOfEntry(ByVal TargetArray As ArrayList, ByVal Entry As Object) As ArrayList
If TargetArray Is Nothing Then Throw New ArgumentNullException("TargetArray")
If TargetArray Is Nothing Then Throw New ArgumentNullException(NameOf(TargetArray))
Dim Indexes As New ArrayList
For Index As Integer = 0 To TargetArray.Count - 1
Dim ArrayEntry As Object = TargetArray(Index)
Expand Down
20 changes: 10 additions & 10 deletions Extensification/Dictionary.vb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Namespace DictionaryExts
''' <returns>Key from value</returns>
<Extension>
Public Function GetKeyFromValue(Of TKey, TValue)(ByVal Dict As Dictionary(Of TKey, TValue), ByVal Value As TValue) As TKey
If Dict Is Nothing Then Throw New ArgumentNullException("Dict")
If Dict Is Nothing Then Throw New ArgumentNullException(NameOf(Dict))
For Each DictKey As TKey In Dict.Keys
If Dict(DictKey).Equals(Value) Then
Return DictKey
Expand All @@ -32,7 +32,7 @@ Namespace DictionaryExts
''' <returns>Index of key</returns>
<Extension>
Public Function GetIndexOfKey(Of TKey, TValue)(ByVal Dict As Dictionary(Of TKey, TValue), ByVal Key As TKey) As Integer
If Dict Is Nothing Then Throw New ArgumentNullException("Dict")
If Dict Is Nothing Then Throw New ArgumentNullException(NameOf(Dict))
Dim DetectedIndex As Integer = 0
For Index As Integer = 0 To Dict.Count - 1
Dim ListEntry As Object = Dict.Keys(Index)
Expand All @@ -51,9 +51,9 @@ Namespace DictionaryExts
''' <param name="Dict">Target dictionary</param>
''' <returns>Count of non-empty values</returns>
<Extension>
Public Function CountFullEntries(Of TKey, TValue)(Dict As Dictionary(Of TKey, TValue)) As Long
Dim FullEntries As Long
For i As Long = 0 To Dict.LongCount - 1
Public Function CountFullEntries(Of TKey, TValue)(Dict As Dictionary(Of TKey, TValue)) As Integer
Dim FullEntries As Integer
For i As Long = 0 To Dict.Count - 1
If Dict.Values(i) IsNot Nothing Then
If TypeOf Dict.Values(i) Is String Then
If Not Dict.Values(i).Equals("") Then
Expand All @@ -75,9 +75,9 @@ Namespace DictionaryExts
''' <param name="Dict">Target dictionary</param>
''' <returns>Count of empty values</returns>
<Extension>
Public Function CountEmptyEntries(Of TKey, TValue)(Dict As Dictionary(Of TKey, TValue)) As Long
Dim EmptyEntries As Long
For i As Long = 0 To Dict.LongCount - 1
Public Function CountEmptyEntries(Of TKey, TValue)(Dict As Dictionary(Of TKey, TValue)) As Integer
Dim EmptyEntries As Integer
For i As Long = 0 To Dict.Count - 1
If Dict.Values(i) Is Nothing Then
EmptyEntries += 1
ElseIf TypeOf Dict.Values(i) Is String And Dict.Values(i).Equals("") Then
Expand All @@ -97,7 +97,7 @@ Namespace DictionaryExts
<Extension>
Public Function GetIndexesOfFullEntries(Of TKey, TValue)(Dict As Dictionary(Of TKey, TValue)) As Integer()
Dim FullIndexes As New List(Of Integer)
For i As Long = 0 To Dict.LongCount - 1
For i As Long = 0 To Dict.Count - 1
If Dict.Values(i) IsNot Nothing Then
If TypeOf Dict.Values(i) Is String Then
If Not Dict.Values(i).Equals("") Then
Expand All @@ -121,7 +121,7 @@ Namespace DictionaryExts
<Extension>
Public Function GetIndexesOfEmptyEntries(Of TKey, TValue)(Dict As Dictionary(Of TKey, TValue)) As Integer()
Dim EmptyIndexes As New List(Of Integer)
For i As Long = 0 To Dict.LongCount - 1
For i As Long = 0 To Dict.Count - 1
If Dict.Values(i) Is Nothing Then
EmptyIndexes.Add(i)
ElseIf TypeOf Dict.Values(i) Is String And Dict.Values(i).Equals("") Then
Expand Down
16 changes: 8 additions & 8 deletions Extensification/List.vb
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ Namespace ListExts
''' <param name="TargetList">Target list</param>
''' <returns>Count of non-empty items</returns>
<Extension>
Public Function CountFullEntries(Of T)(TargetList As List(Of T)) As Long
Dim FullEntries As Long
For i As Long = 0 To TargetList.LongCount - 1
Public Function CountFullEntries(Of T)(TargetList As List(Of T)) As Integer
Dim FullEntries As Integer
For i As Long = 0 To TargetList.Count - 1
If TargetList(i) IsNot Nothing Then
If TypeOf TargetList(i) Is String Then
If Not TargetList(i).Equals("") Then
Expand All @@ -63,9 +63,9 @@ Namespace ListExts
''' <param name="TargetList">Target list</param>
''' <returns>Count of empty items</returns>
<Extension>
Public Function CountEmptyEntries(Of T)(TargetList As List(Of T)) As Long
Dim EmptyEntries As Long
For i As Long = 0 To TargetList.LongCount - 1
Public Function CountEmptyEntries(Of T)(TargetList As List(Of T)) As Integer
Dim EmptyEntries As Integer
For i As Long = 0 To TargetList.Count - 1
If TargetList(i) Is Nothing Then
EmptyEntries += 1
ElseIf TypeOf TargetList(i) Is String And TargetList(i).Equals("") Then
Expand All @@ -84,7 +84,7 @@ Namespace ListExts
<Extension>
Public Function GetIndexesOfFullEntries(Of T)(TargetList As List(Of T)) As Integer()
Dim FullIndexes As New List(Of Integer)
For i As Long = 0 To TargetList.LongCount - 1
For i As Long = 0 To TargetList.Count - 1
If TargetList(i) IsNot Nothing Then
If TypeOf TargetList(i) Is String Then
If Not TargetList(i).Equals("") Then
Expand All @@ -107,7 +107,7 @@ Namespace ListExts
<Extension>
Public Function GetIndexesOfEmptyEntries(Of T)(TargetList As List(Of T)) As Integer()
Dim EmptyIndexes As New List(Of Integer)
For i As Long = 0 To TargetList.LongCount - 1
For i As Long = 0 To TargetList.Count - 1
If TargetList(i) Is Nothing Then
EmptyIndexes.Add(i)
ElseIf TypeOf TargetList(i) Is String And TargetList(i).Equals("") Then
Expand Down
Loading

0 comments on commit 6bb1d7a

Please sign in to comment.