Skip to content

Commit

Permalink
#75 cast ArrayList to IList(Of RoleInfo)
Browse files Browse the repository at this point in the history
  • Loading branch information
skamphuis committed Jan 11, 2022
1 parent 2dc19c6 commit 1ef98de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Components/Common.vb
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,18 @@ Namespace Ventrian.NewsArticles
return retval
End Function

Public shared Function ToList(Of T As Class)(objArrayList As ArrayList) As List(Of T)
Dim retval As New List(Of T)()

For Each objItem As Object In objArrayList
Dim newItem As T = TryCast(objItem, T)
If Not newItem Is Nothing Then
retval.Add(newItem)
End If
Next

Return retval
End Function

#End Region

Expand Down
4 changes: 2 additions & 2 deletions ucViewOptions.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ Namespace Ventrian.NewsArticles
roles = RoleController.Instance.GetRoles(PortalId)
Else
Dim objRole As New RoleController
roles = objRole.GetRolesByGroup(PortalId, Convert.ToInt32(drpSecurityRoleGroups.SelectedValue))
roles = Common.ToList(Of RoleInfo)(objRole.GetRolesByGroup(PortalId, Convert.ToInt32(drpSecurityRoleGroups.SelectedValue)))
End If

If Not roles Is Nothing Then
For Each Role As RoleInfo In roles
availableRoles.Add(New ListItem(Role.RoleName, Role.RoleName))
Expand Down

0 comments on commit 1ef98de

Please sign in to comment.