From 1ef98de06aced6ae16c993c291c6297c31175ffb Mon Sep 17 00:00:00 2001 From: Stefan Kamphuis Date: Tue, 11 Jan 2022 13:51:31 +0100 Subject: [PATCH] #75 cast ArrayList to IList(Of RoleInfo) --- Components/Common.vb | 12 ++++++++++++ ucViewOptions.ascx.vb | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Components/Common.vb b/Components/Common.vb index e1233cd..ee21bd0 100755 --- a/Components/Common.vb +++ b/Components/Common.vb @@ -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 diff --git a/ucViewOptions.ascx.vb b/ucViewOptions.ascx.vb index bf8dd19..1b9b8ea 100755 --- a/ucViewOptions.ascx.vb +++ b/ucViewOptions.ascx.vb @@ -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))