RE: issue when converting C#.net code into vb.net
am 29.01.2008 17:52:28 von DavidAnton
The following conversion should be pretty close - however, Instant VB can't
determine the return types of the extracted methods (since VB doesn't have
anonymous methods - see the 'delegate' keyword in your original code), so it
uses 'Object' - you'll have to adjust these:
_
Public Shared Function GetMembers(ByVal returnAllApprovedUsers As Boolean,
ByVal returnAllNotApprovedUsers As Boolean, ByVal usernameToFind As String,
ByVal sortData As String) As List(Of MembershipUserWrapper)
Dim memberList As List(Of MembershipUserWrapper) = New List(Of
MembershipUserWrapper)()
' See if we are looking for just one user
If usernameToFind IsNot Nothing Then
Dim mu As MembershipUser = Membership.GetUser(usernameToFind)
If mu IsNot Nothing Then
Dim md As New MembershipUserWrapper(mu)
memberList.Add(md)
End If
Else
Dim muc As MembershipUserCollection = Membership.GetAllUsers()
For Each mu As MembershipUser In muc
If (returnAllApprovedUsers = True AndAlso mu.IsApproved = True) OrElse
(returnAllNotApprovedUsers = True AndAlso mu.IsApproved = False) Then
Dim md As New MembershipUserWrapper(mu)
memberList.Add(md)
End If
Next mu
If sortData Is Nothing Then
sortData = "UserName"
End If
If sortData.Length = 0 Then
sortData = "UserName"
End If
Dim sortDataBase As String = sortData
Dim descString As String = " DESC"
If sortData.EndsWith(descString) Then
sortDataBase = sortData.Substring(0, sortData.Length - descString.Length)
End If
Dim comparison As Comparison(Of MembershipUserWrapper) = Nothing
Select Case sortDataBase
Case "UserName"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod1)
Case "Email"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod2)
Case "CreationDate"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod3)
Case "IsApproved"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod4)
Case "IsOnline"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod5)
Case "LastLoginDate"
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod6)
Case Else
comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod7)
End Select
If sortData.EndsWith("DESC") Then
memberList.Sort(comparison)
memberList.Reverse()
Else
memberList.Sort(comparison)
End If
End If
Return memberList
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod1(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.UserName.CompareTo(rhs.UserName)
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod2(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
If lhs.Email Is Nothing Or rhs.Email Is Nothing Then
Return 0
Else
Return lhs.Email.CompareTo(rhs.Email)
End If
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod3(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.CreationDate.CompareTo(rhs.CreationDate)
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod4(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.IsApproved.CompareTo(rhs.IsApproved)
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod5(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.IsOnline.CompareTo(rhs.IsOnline)
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod6(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.LastLoginDate.CompareTo(rhs.LastLoginDate)
End Function
'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
could not be determined by Instant VB:
Private Shared Function AnonymousMethod7(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.UserName.CompareTo(rhs.UserName)
End Function
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++ VB Edition: VB to C++/CLI
Instant C++ C# Edition: C# to C++/CLI
"Dhananjay" wrote:
> Hi All,
>
> I am facing problem when i am converting C#.net code(Delegate concept)
> into vb.net. I am unable to do that . Can someone help me to solve the
> problem. I am providing my C#.net code.
>
> ==================================my code is :-
> ======================================
> [DataObjectMethod(DataObjectMethodType.Select, false)]
> static public List GetMembers(bool
> returnAllApprovedUsers, bool returnAllNotApprovedUsers,
> string usernameToFind, string sortData)
> {
>
> List memberList = new
> List();
>
> // See if we are looking for just one user
> if (usernameToFind != null)
> {
> MembershipUser mu =
> Membership.GetUser(usernameToFind);
> if (mu != null)
> {
> MembershipUserWrapper md = new
> MembershipUserWrapper(mu);
> memberList.Add(md);
> }
> }
> else
> {
> MembershipUserCollection muc =
> Membership.GetAllUsers();
> foreach (MembershipUser mu in muc)
> {
> if ((returnAllApprovedUsers == true &&
> mu.IsApproved == true) ||
> (returnAllNotApprovedUsers == true &&
> mu.IsApproved == false))
> {
> MembershipUserWrapper md = new
> MembershipUserWrapper(mu);
> memberList.Add(md);
> }
> }
>
> if (sortData == null)
> {
> sortData = "UserName";
> }
> if (sortData.Length == 0)
> {
> sortData = "UserName";
> }
>
>
> string sortDataBase = sortData;
> string descString = " DESC";
> if (sortData.EndsWith(descString))
> {
> sortDataBase = sortData.Substring(0,
> sortData.Length - descString.Length);
> }
>
> Comparison comparison = null;
>
> switch (sortDataBase)
> {
> case "UserName":
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> return
> lhs.UserName.CompareTo(rhs.UserName);
> }
> );
> break;
> case "Email":
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> if (lhs.Email == null | rhs.Email ==
> null)
> {
> return 0;
> }
> else
> {
> return
> lhs.Email.CompareTo(rhs.Email);
> }
> }
> );
> break;
> case "CreationDate":
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> return
> lhs.CreationDate.CompareTo(rhs.CreationDate);
> }
> );
> break;
> case "IsApproved":
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> return
> lhs.IsApproved.CompareTo(rhs.IsApproved);
> }
> );
> break;
> case "IsOnline":
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> return
> lhs.IsOnline.CompareTo(rhs.IsOnline);
> }
> );
> break;
> case "LastLoginDate":
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> return
> lhs.LastLoginDate.CompareTo(rhs.LastLoginDate);
> }
> );
> break;
> default:
> comparison = new
> Comparison(
> delegate(MembershipUserWrapper lhs,
> MembershipUserWrapper rhs)
> {
> return
> lhs.UserName.CompareTo(rhs.UserName);
> }
> );
> break;
> }
>
> if (sortData.EndsWith("DESC"))
> {
> memberList.Sort(comparison);
> memberList.Reverse();
> }
> else
> {
> memberList.Sort(comparison);
> }
>
> }
>
> return memberList;
>
> }
> ====================================C#.net code
> end==================================
>
> now i want this part of code into vb.net code , can some one please
> provide me the solution.
> I had tried writing myself C#.net code into vb.net code but unable to
> acheive correct vb.net code.I had used some conversion tool also from
> developer fusion site but it is showing error that is some different
> kind of error.Please provide me the vb.net code.
> it's urgent
>
> Thanks in advance
> Dhananjay
>
Re: issue when converting C#.net code into vb.net
am 29.01.2008 21:02:17 von Dhananjay
On Jan 29, 9:52 pm, David Anton
wrote:
> The following conversion should be pretty close - however, Instant VB can'=
t
> determine the return types of the extracted methods (since VB doesn't have=
> anonymous methods - see the 'delegate' keyword in your original code), so =
it
> uses 'Object' - you'll have to adjust these:
>
> _
> Public Shared Function GetMembers(ByVal returnAllApprovedU=
sers As Boolean,
> ByVal returnAllNotApprovedUsers As Boolean, ByVal usernameToFind As String=
,
> ByVal sortData As String) As List(Of MembershipUserWrapper)
>
> Dim memberList As List(Of MembershipUserWrapper) =
=3D New List(Of
> MembershipUserWrapper)()
>
> ' See if we are looking for just one user
> If usernameToFind IsNot Nothing Then
> Dim mu As MembershipUser =3D Membership.Ge=
tUser(usernameToFind)
> If mu IsNot Nothing Then
> Dim md As New MembershipUserWrappe=
r(mu)
> memberList.Add(md)
> End If
> Else
> Dim muc As MembershipUserCollection =3D Me=
mbership.GetAllUsers()
> For Each mu As MembershipUser In muc
> If (returnAllApprovedUsers =3D Tru=
e AndAlso mu.IsApproved =3D True) OrElse
> (returnAllNotApprovedUsers =3D True AndAlso mu.IsApproved =3D False) Then
> Dim md As New MembershipUs=
erWrapper(mu)
> memberList.Add(md)
> End If
> Next mu
>
> If sortData Is Nothing Then
> sortData =3D "UserName"
> End If
> If sortData.Length =3D 0 Then
> sortData =3D "UserName"
> End If
>
> Dim sortDataBase As String =3D sortData
> Dim descString As String =3D " DESC"
> If sortData.EndsWith(descString) Then
> sortDataBase =3D sortData.Substrin=
g(0, sortData.Length - descString.Length)
> End If
>
> Dim comparison As Comparison(Of Membership=
UserWrapper) =3D Nothing
>
> Select Case sortDataBase
> Case "UserName"
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod1)
> Case "Email"
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod2)
> Case "CreationDate"
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod3)
> Case "IsApproved"
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod4)
> Case "IsOnline"
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod5)
> Case "LastLoginDate"
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod6)
> Case Else
> comparison =3D New Compari=
son(Of MembershipUserWrapper)(AddressOf
> AnonymousMethod7)
> End Select
>
> If sortData.EndsWith("DESC") Then
> memberList.Sort(comparison)
> memberList.Reverse()
> Else
> memberList.Sort(comparison)
> End If
>
> End If
> Return memberList
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod1(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> Return lhs.UserName.CompareTo(rhs.UserName)
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod2(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> If lhs.Email Is Nothing Or rhs.Email Is Nothing Th=
en
> Return 0
> Else
> Return lhs.Email.CompareTo(rhs.Email)
> End If
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod3(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> Return lhs.CreationDate.CompareTo(rhs.CreationDate=
)
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod4(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> Return lhs.IsApproved.CompareTo(rhs.IsApproved)
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod5(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> Return lhs.IsOnline.CompareTo(rhs.IsOnline)
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod6(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> Return lhs.LastLoginDate.CompareTo(rhs.LastLoginDa=
te)
> End Function
> 'TODO: INSTANT VB TODO TASK: The return type of this anony=
mous method
> could not be determined by Instant VB:
> Private Shared Function AnonymousMethod7(ByVal lhs As
> MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> Return lhs.UserName.CompareTo(rhs.UserName)
> End Function
>
> --http://www.tangiblesoftwaresolutions.com
> C++ to C#
> C++ to VB
> C++ to Java
> Instant C#: VB to C#
> Instant VB: C# to VB
> Instant C++ VB Edition: VB to C++/CLI
> Instant C++ C# Edition: C# to C++/CLI
>
> "Dhananjay" wrote:
> > Hi All,
>
> > I am facing problem when i am converting C#.net code(Delegate concept)
> > into vb.net. I am unable to do that . Can someone help me to solve the
> > problem. I am providing my C#.net code.
>
> > ==================== =====
==========my code is :-
> > ==================== =====
==============
> > [DataObjectMethod(DataObjectMethodType.Select, false)]
> > static public List GetMembers(bool
> > returnAllApprovedUsers, bool returnAllNotApprovedUsers,
> > string usernameToFind, string sortData)
> > {
>
> > List memberList =3D new
> > List();
>
> > // See if we are looking for just one user
> > if (usernameToFind !=3D null)
> > {
> > MembershipUser mu =3D
> > Membership.GetUser(usernameToFind);
> > if (mu !=3D null)
> > {
> > MembershipUserWrapper md =3D new
> > MembershipUserWrapper(mu);
> > memberList.Add(md);
> > }
> > }
> > else
> > {
> > MembershipUserCollection muc =3D
> > Membership.GetAllUsers();
> > foreach (MembershipUser mu in muc)
> > {
> > if ((returnAllApprovedUsers == true &&
> > mu.IsApproved == true) ||
> > (returnAllNotApprovedUsers == true &&
> > mu.IsApproved == false))
> > {
> > MembershipUserWrapper md =3D new
> > MembershipUserWrapper(mu);
> > memberList.Add(md);
> > }
> > }
>
> > if (sortData == null)
> > {
> > sortData =3D "UserName";
> > }
> > if (sortData.Length == 0)
> > {
> > sortData =3D "UserName";
> > }
>
> > string sortDataBase =3D sortData;
> > string descString =3D " DESC";
> > if (sortData.EndsWith(descString))
> > {
> > sortDataBase =3D sortData.Substring(0,
> > sortData.Length - descString.Length);
> > }
>
> > Comparison comparison =3D null;
>
> > switch (sortDataBase)
> > {
> > case "UserName":
> > comparison =3D new
> > Comparison(
> > delegate(MembershipUserWrapper lhs,
> > MembershipUserWrapper rhs)
> > {
> > return
> > lhs.UserName.CompareTo(rhs.UserName);
> > }
> > );
> > break;
> > case "Email":
> > comparison =3D new
> > Comparison(
> > delegate(MembershipUserWrapper lhs,
> > MembershipUserWrapper rhs)
> > {
> > if (lhs.Email == null | rhs.Email =
==
> > null)
> > {
> > return 0;
> > }
> > else
> > {
> > return
> > lhs.Email.CompareTo(rhs.Email);
> > }
> > }
> > );
> > break;
> > case "CreationDate":
> > comparison =3D new
> > Comparison(
> > delegate(MembershipUserWrapper lhs,
> > MembershipUserWrapper rhs)
> > {
> > return
> > lhs.CreationDate.CompareTo(rhs.CreationDate);
> > }
> > );
> > break;
> > case "IsApproved":
> > comparison =3D new
> > Comparison(
> > delegate(MembershipUserWrapper lhs,
> > MembershipUserWrapper rhs)
> > {
> > return
> > lhs.IsApproved.CompareTo(rhs.IsApproved);
> > }
> > );
> > break;
> > case "IsOnline":
> > comparison =3D new
> > Comparison(
> > delegate(MembershipUserWrapper lhs,
> > MembershipUserWrapper rhs)
> > {
> > return
> > lhs.IsOnline.CompareTo(rhs.IsOnline);
> > }
> > );
> > break;
> > case "LastLoginDate":
> > comparison =3D new
>
> ...
>
> read more =BB
Hi David,
First of all thanks a lot for help.
After copying the vb.net converted code( which i required) given by
you, I have got an error (Address Of AnonymousMethod) which says ''
method 'private shared function AnonymousMethod7(lhs as
membershipUtilities.membershipUserWrapper, rhs as
membershipUtilities.membershipUserWrapper ) As Object' doesn't have
same signature As delegate 'Delegate Function Comparision(Of T) (x as
membershipUserWrapper, y as membershipUserWrapper) As Integer ''
How do i proceed please guide me as earliest as possible
Thanks in advance
Dhananjay
Re: issue when converting C#.net code into vb.net
am 29.01.2008 21:40:03 von DavidAnton
Just change the signature of the converted method to match the delegate.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++ VB Edition: VB to C++/CLI
Instant C++ C# Edition: C# to C++/CLI
"Dhananjay" wrote:
> On Jan 29, 9:52 pm, David Anton
> wrote:
> > The following conversion should be pretty close - however, Instant VB can't
> > determine the return types of the extracted methods (since VB doesn't have
> > anonymous methods - see the 'delegate' keyword in your original code), so it
> > uses 'Object' - you'll have to adjust these:
> >
> > _
> > Public Shared Function GetMembers(ByVal returnAllApprovedUsers As Boolean,
> > ByVal returnAllNotApprovedUsers As Boolean, ByVal usernameToFind As String,
> > ByVal sortData As String) As List(Of MembershipUserWrapper)
> >
> > Dim memberList As List(Of MembershipUserWrapper) = New List(Of
> > MembershipUserWrapper)()
> >
> > ' See if we are looking for just one user
> > If usernameToFind IsNot Nothing Then
> > Dim mu As MembershipUser = Membership.GetUser(usernameToFind)
> > If mu IsNot Nothing Then
> > Dim md As New MembershipUserWrapper(mu)
> > memberList.Add(md)
> > End If
> > Else
> > Dim muc As MembershipUserCollection = Membership.GetAllUsers()
> > For Each mu As MembershipUser In muc
> > If (returnAllApprovedUsers = True AndAlso mu.IsApproved = True) OrElse
> > (returnAllNotApprovedUsers = True AndAlso mu.IsApproved = False) Then
> > Dim md As New MembershipUserWrapper(mu)
> > memberList.Add(md)
> > End If
> > Next mu
> >
> > If sortData Is Nothing Then
> > sortData = "UserName"
> > End If
> > If sortData.Length = 0 Then
> > sortData = "UserName"
> > End If
> >
> > Dim sortDataBase As String = sortData
> > Dim descString As String = " DESC"
> > If sortData.EndsWith(descString) Then
> > sortDataBase = sortData.Substring(0, sortData.Length - descString.Length)
> > End If
> >
> > Dim comparison As Comparison(Of MembershipUserWrapper) = Nothing
> >
> > Select Case sortDataBase
> > Case "UserName"
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod1)
> > Case "Email"
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod2)
> > Case "CreationDate"
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod3)
> > Case "IsApproved"
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod4)
> > Case "IsOnline"
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod5)
> > Case "LastLoginDate"
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod6)
> > Case Else
> > comparison = New Comparison(Of MembershipUserWrapper)(AddressOf
> > AnonymousMethod7)
> > End Select
> >
> > If sortData.EndsWith("DESC") Then
> > memberList.Sort(comparison)
> > memberList.Reverse()
> > Else
> > memberList.Sort(comparison)
> > End If
> >
> > End If
> > Return memberList
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod1(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > Return lhs.UserName.CompareTo(rhs.UserName)
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod2(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > If lhs.Email Is Nothing Or rhs.Email Is Nothing Then
> > Return 0
> > Else
> > Return lhs.Email.CompareTo(rhs.Email)
> > End If
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod3(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > Return lhs.CreationDate.CompareTo(rhs.CreationDate)
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod4(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > Return lhs.IsApproved.CompareTo(rhs.IsApproved)
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod5(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > Return lhs.IsOnline.CompareTo(rhs.IsOnline)
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod6(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > Return lhs.LastLoginDate.CompareTo(rhs.LastLoginDate)
> > End Function
> > 'TODO: INSTANT VB TODO TASK: The return type of this anonymous method
> > could not be determined by Instant VB:
> > Private Shared Function AnonymousMethod7(ByVal lhs As
> > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > Return lhs.UserName.CompareTo(rhs.UserName)
> > End Function
> >
> > --http://www.tangiblesoftwaresolutions.com
> > C++ to C#
> > C++ to VB
> > C++ to Java
> > Instant C#: VB to C#
> > Instant VB: C# to VB
> > Instant C++ VB Edition: VB to C++/CLI
> > Instant C++ C# Edition: C# to C++/CLI
> >
> > "Dhananjay" wrote:
> > > Hi All,
> >
> > > I am facing problem when i am converting C#.net code(Delegate concept)
> > > into vb.net. I am unable to do that . Can someone help me to solve the
> > > problem. I am providing my C#.net code.
> >
> > > ==================================my code is :-
> > > ======================================
> > > [DataObjectMethod(DataObjectMethodType.Select, false)]
> > > static public List GetMembers(bool
> > > returnAllApprovedUsers, bool returnAllNotApprovedUsers,
> > > string usernameToFind, string sortData)
> > > {
> >
> > > List memberList = new
> > > List();
> >
> > > // See if we are looking for just one user
> > > if (usernameToFind != null)
> > > {
> > > MembershipUser mu =
> > > Membership.GetUser(usernameToFind);
> > > if (mu != null)
> > > {
> > > MembershipUserWrapper md = new
> > > MembershipUserWrapper(mu);
> > > memberList.Add(md);
> > > }
> > > }
> > > else
> > > {
> > > MembershipUserCollection muc =
> > > Membership.GetAllUsers();
> > > foreach (MembershipUser mu in muc)
> > > {
> > > if ((returnAllApprovedUsers == true &&
> > > mu.IsApproved == true) ||
> > > (returnAllNotApprovedUsers == true &&
> > > mu.IsApproved == false))
> > > {
> > > MembershipUserWrapper md = new
> > > MembershipUserWrapper(mu);
> > > memberList.Add(md);
> > > }
> > > }
> >
> > > if (sortData == null)
> > > {
> > > sortData = "UserName";
> > > }
> > > if (sortData.Length == 0)
> > > {
> > > sortData = "UserName";
> > > }
> >
> > > string sortDataBase = sortData;
> > > string descString = " DESC";
> > > if (sortData.EndsWith(descString))
> > > {
> > > sortDataBase = sortData.Substring(0,
> > > sortData.Length - descString.Length);
> > > }
> >
> > > Comparison comparison = null;
> >
> > > switch (sortDataBase)
> > > {
> > > case "UserName":
> > > comparison = new
> > > Comparison(
> > > delegate(MembershipUserWrapper lhs,
> > > MembershipUserWrapper rhs)
> > > {
> > > return
> > > lhs.UserName.CompareTo(rhs.UserName);
> > > }
> > > );
> > > break;
> > > case "Email":
> > > comparison = new
> > > Comparison(
> > > delegate(MembershipUserWrapper lhs,
> > > MembershipUserWrapper rhs)
> > > {
> > > if (lhs.Email == null | rhs.Email ==
> > > null)
> > > {
> > > return 0;
> > > }
> > > else
> > > {
> > > return
> > > lhs.Email.CompareTo(rhs.Email);
> > > }
> > > }
> > > );
> > > break;
> > > case "CreationDate":
> > > comparison = new
> > > Comparison(
> > > delegate(MembershipUserWrapper lhs,
> > > MembershipUserWrapper rhs)
> > > {
> > > return
> > > lhs.CreationDate.CompareTo(rhs.CreationDate);
> > > }
> > > );
> > > break;
> > > case "IsApproved":
> > > comparison = new
> > > Comparison(
> > > delegate(MembershipUserWrapper lhs,
> > > MembershipUserWrapper rhs)
> > > {
> > > return
> > > lhs.IsApproved.CompareTo(rhs.IsApproved);
> > > }
> > > );
> > > break;
> > > case "IsOnline":
> > > comparison = new
> > > Comparison(
> > > delegate(MembershipUserWrapper lhs,
> > > MembershipUserWrapper rhs)
> > > {
> > > return
> > > lhs.IsOnline.CompareTo(rhs.IsOnline);
> > > }
> > > );
> > > break;
> > > case "LastLoginDate":
> > > comparison = new
> >
> > ...
> >
> > read more »
>
>
>
> Hi David,
>
> First of all thanks a lot for help.
> After copying the vb.net converted code( which i required) given by
> you, I have got an error (Address Of AnonymousMethod) which says ''
> method 'private shared function AnonymousMethod7(lhs as
> membershipUtilities.membershipUserWrapper, rhs as
> membershipUtilities.membershipUserWrapper ) As Object' doesn't have
> same signature As delegate 'Delegate Function Comparision(Of T) (x as
> membershipUserWrapper, y as membershipUserWrapper) As Integer ''
>
> How do i proceed please guide me as earliest as possible
>
>
> Thanks in advance
> Dhananjay
>
Re: issue when converting C#.net code into vb.net
am 31.01.2008 16:39:04 von Dhananjay
On Jan 30, 1:40 am, David Anton
wrote:
> Just change the signature of the converted method to match the delegate.
> --http://www.tangiblesoftwaresolutions.com
> C++ to C#
> C++ to VB
> C++ to Java
> Instant C#: VB to C#
> Instant VB: C# to VB
> Instant C++ VB Edition: VB to C++/CLI
> Instant C++ C# Edition: C# to C++/CLI
>
> "Dhananjay" wrote:
> > On Jan 29, 9:52 pm, David Anton
> > wrote:
> > > The following conversion should be pretty close - however, Instant VB =
can't
> > > determine the return types of the extracted methods (since VB doesn't =
have
> > > anonymous methods - see the 'delegate' keyword in your original code),=
so it
> > > uses 'Object' - you'll have to adjust these:
>
> > > =
_
> > > Public Shared Function GetMembers(ByVal returnAllAppro=
vedUsers As Boolean,
> > > ByVal returnAllNotApprovedUsers As Boolean, ByVal usernameToFind As St=
ring,
> > > ByVal sortData As String) As List(Of MembershipUserWrapper)
>
> > > Dim memberList As List(Of MembershipUserWrappe=
r) =3D New List(Of
> > > MembershipUserWrapper)()
>
> > > ' See if we are looking for just one user
> > > If usernameToFind IsNot Nothing Then
> > > Dim mu As MembershipUser =3D Membershi=
p.GetUser(usernameToFind)
> > > If mu IsNot Nothing Then
> > > Dim md As New MembershipUserWr=
apper(mu)
> > > memberList.Add(md)
> > > End If
> > > Else
> > > Dim muc As MembershipUserCollection =
=3D Membership.GetAllUsers()
> > > For Each mu As MembershipUser In muc
> > > If (returnAllApprovedUsers =3D=
True AndAlso mu.IsApproved =3D True) OrElse
> > > (returnAllNotApprovedUsers =3D True AndAlso mu.IsApproved =3D False) T=
hen
> > > Dim md As New Membersh=
ipUserWrapper(mu)
> > > memberList.Add(md)
> > > End If
> > > Next mu
>
> > > If sortData Is Nothing Then
> > > sortData =3D "UserName"
> > > End If
> > > If sortData.Length =3D 0 Then
> > > sortData =3D "UserName"
> > > End If
>
> > > Dim sortDataBase As String =3D sortDat=
a
> > > Dim descString As String =3D " DESC"
> > > If sortData.EndsWith(descString) Then
> > > sortDataBase =3D sortData.Subs=
tring(0, sortData.Length - descString.Length)
> > > End If
>
> > > Dim comparison As Comparison(Of Member=
shipUserWrapper) =3D Nothing
>
> > > Select Case sortDataBase
> > > Case "UserName"
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod1)
> > > Case "Email"
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod2)
> > > Case "CreationDate"
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod3)
> > > Case "IsApproved"
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod4)
> > > Case "IsOnline"
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod5)
> > > Case "LastLoginDate"
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod6)
> > > Case Else
> > > comparison =3D New Com=
parison(Of MembershipUserWrapper)(AddressOf
> > > AnonymousMethod7)
> > > End Select
>
> > > If sortData.EndsWith("DESC") Then
> > > memberList.Sort(comparison)
> > > memberList.Reverse()
> > > Else
> > > memberList.Sort(comparison)
> > > End If
>
> > > End If
> > > Return memberList
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod1(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > Return lhs.UserName.CompareTo(rhs.UserName)
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod2(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > If lhs.Email Is Nothing Or rhs.Email Is Nothin=
g Then
> > > Return 0
> > > Else
> > > Return lhs.Email.CompareTo(rhs.Email)
> > > End If
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod3(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > Return lhs.CreationDate.CompareTo(rhs.Creation=
Date)
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod4(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > Return lhs.IsApproved.CompareTo(rhs.IsApproved=
)
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod5(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > Return lhs.IsOnline.CompareTo(rhs.IsOnline)
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod6(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > Return lhs.LastLoginDate.CompareTo(rhs.LastLog=
inDate)
> > > End Function
> > > 'TODO: INSTANT VB TODO TASK: The return type of this a=
nonymous method
> > > could not be determined by Instant VB:
> > > Private Shared Function AnonymousMethod7(ByVal lhs As
> > > MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
> > > Return lhs.UserName.CompareTo(rhs.UserName)
> > > End Function
>
> > > --http://www.tangiblesoftwaresolutions.com
> > > C++ to C#
> > > C++ to VB
> > > C++ to Java
> > > Instant C#: VB to C#
> > > Instant VB: C# to VB
> > > Instant C++ VB Edition: VB to C++/CLI
> > > Instant C++ C# Edition: C# to C++/CLI
>
> > > "Dhananjay" wrote:
> > > > Hi All,
>
> > > > I am facing problem when i am converting C#.net code(Delegate concep=
t)
> > > > into vb.net. I am unable to do that . Can someone help me to solve t=
he
> > > > problem. I am providing my C#.net code.
>
> > > > ==================== ===
============my code is :-
> > > > ==================== ===
================
> > > > [DataObjectMethod(DataObjectMethodType.Select, false)]
> > > > static public List GetMembers(bool
> > > > returnAllApprovedUsers, bool returnAllNotApprovedUsers,
> > > > string usernameToFind, string sortData)
> > > > {
>
> > > > List memberList =3D new
> > > > List();
>
> > > > // See if we are looking for just one user
> > > > if (usernameToFind !=3D null)
> > > > {
> > > > MembershipUser mu =3D
> > > > Membership.GetUser(usernameToFind);
> > > > if (mu !=3D null)
> > > > {
> > > > MembershipUserWrapper md =3D new
> > > > MembershipUserWrapper(mu);
> > > > memberList.Add(md);
> > > > }
> > > > }
> > > > else
> > > > {
> > > > MembershipUserCollection muc =3D
> > > > Membership.GetAllUsers();
> > > > foreach (MembershipUser mu in muc)
> > > > {
> > > > if ((returnAllApprovedUsers == true &&
> > > > mu.IsApproved == true) ||
> > > > (returnAllNotApprovedUsers == true &&
> > > > mu.IsApproved == false))
> > > > {
> > > > MembershipUserWrapper md =3D new
> > > > MembershipUserWrapper(mu);
> > > > memberList.Add(md);
> > > > }
>
> ...
>
> read more =BB
Hi David,
Thanks a lot for reply.
Here in i am providing my both code files , can you please see where
is the problem. I have tried to correct it but it was not
successful.can you please provide me correct complete code. The
problem is same which i mentioned you. It gives error on Anonymous
method(i.e; Delegate concept).In the last reply you told me to change
the signature of method.problem lies in MembershipUserODS file.
please have a look and try to correct the code.Thanks in advance.
==================== =====3D=
=======3DMemebershipUserODS.vb file
==================== =====3D=
==================== =====3D=
===========3D
Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Globalization
Imports System.Collections.ObjectModel
Namespace MembershipUtilities
'''
''' Class Used to Select, Update, Insert and Delete
''' From the Microsoft ASP.NET Membership API
'''
'''
_
Public Class MembershipUserODS
'''
''' This insert method is the default insert method. It is
typically associated with
''' a detailview control for inserting new members.
'''
''' MembershipUser.UserName
''' MembershipUser.password
''' MembershipUser.IsApproved
''' MembershipUser.comment
''' MembershipUser.lastLockoutDate
param>
''' MembershipUser.creationDate
''' MembershipUser.email
''' MembershipUser.lastActivityDate
param>
''' MembershipUser.providerName
''' MembershipUser.isLockedOut
''' MembershipUser.lastLoginDate
''' MembershipUser.isOnline
''' MembershipUser.passwordQuestion
param>
'''
name=3D"lastPasswordChangedDate">MembershipUser.lastPassword ChangedDate
param>
'''
_
Public Shared Sub Insert(ByVal userName As String, ByVal isApproved
As Boolean, ByVal comment As String, ByVal lastLockoutDate As
DateTime, ByVal creationDate As DateTime, ByVal email As String, ByVal
lastActivityDate As DateTime, ByVal providerName As String, ByVal
isLockedOut As Boolean, ByVal lastLoginDate As DateTime, ByVal
isOnline As Boolean, ByVal passwordQuestion As String, ByVal
lastPasswordChangedDate As DateTime, ByVal password As String, ByVal
passwordAnswer As String)
' The incoming parameters, password and passwordAnswer are not
properties of the
' MembershipUser class. Membership has special member functions to
deal with these
' two special properties for security reasons. For this reason,
they do not appear
' in a datacontrol that is created with this user object.
'
' the only reason you may want to have defaults is so you can build
insert into your
' datacontrol. A better approach would be to either follow the
example shown in the
' Membership.asp page where the parameters are set directly to the
userobject, or not
' include "new" at all in your control and use the other controls
in the Membership API
' for creating new members. (CreateUserWizard, etc)
'
' It is recommended that you only enable the following lines if you
are sure of what you are doing
'if (password == null)
'{
' password =3D "pass0word";
'}
'if (passwordAnswer == null)
'{
' passwordAnswer =3D "Password Answer";
'}
Dim status As MembershipCreateStatus
Membership.CreateUser(userName, password, email, passwordQuestion,
passwordAnswer, isApproved, status)
If status <> MembershipCreateStatus.Success Then
Throw New ApplicationException(status.ToString())
End If
Dim mu As MembershipUser =3D Membership.GetUser(userName)
mu.Comment =3D comment
Membership.UpdateUser(mu)
End Sub
'''
''' Takes as input the original username and the current username
'''
'''
'''
'''
_
Public Shared Sub Delete(ByVal UserName As String)
Membership.DeleteUser(UserName, True)
End Sub
'''
''' This update method is the default update as shown by the class
attribute.
'''
'''
''' MembershipUser.UserName
originally retrieved
''' MembershipUser.email
''' MembershipUser.isApproved
''' MembershipUser.comment
''' MembershipUser.password
''' MembershipUser.passwordAnswer
param>
''' MembershipUser.lastActivityDate
param>
''' MembershipUser.lastLoginDate
'''
_
Public Shared Sub Update(ByVal UserName As String, ByVal email As
String, ByVal isApproved As Boolean, ByVal comment As String, ByVal
lastActivityDate As DateTime, ByVal lastLoginDate As DateTime)
Dim dirtyFlag As Boolean =3D False
Dim mu As MembershipUser =3D Membership.GetUser(UserName)
If mu.Comment Is Nothing OrElse mu.Comment.CompareTo(comment) <> 0
Then
dirtyFlag =3D True
mu.Comment =3D comment
End If
If mu.Email Is Nothing OrElse mu.Email.CompareTo(email) <> 0 Then
dirtyFlag =3D True
mu.Email =3D email
End If
If mu.IsApproved <> isApproved Then
dirtyFlag =3D True
mu.IsApproved =3D isApproved
End If
If dirtyFlag =3D True Then
Membership.UpdateUser(mu)
End If
End Sub
'''
''' This is just used to set the IsApproved status.
''' username is always passed in for searching purposes.
'''
''' Current UserName to Update
(primary key)
''' MembershipUser.isApproved
'''
_
Public Shared Sub Update(ByVal Username As String, ByVal isApproved
As Boolean)
Dim dirtyFlag As Boolean =3D False
Dim mu As MembershipUser =3D Membership.GetUser(Username)
If mu.IsApproved <> isApproved Then
dirtyFlag =3D True
mu.IsApproved =3D isApproved
End If
If dirtyFlag =3D True Then
Membership.UpdateUser(mu)
End If
End Sub
'''
''' Make a list of MembershipUserWrapper objects
'''
''' A List of type MembershipUserWrapper
'''
_
Public Shared Function GetMembers() As List(Of
MembershipUserWrapper)
Return GetMembers(True, True, Nothing, Nothing)
End Function
'''
''' Make a list of MembershipUserWrapper objects by current sort
'''
''' Whicfh Column to perform the sort on
param>
''' A List of type MembershipUserWrapper
'''
_
Public Shared Function GetMembers(ByVal sortData As String) As
List(Of MembershipUserWrapper)
' All Users, All approvalStatus
Return GetMembers(True, True, Nothing, sortData)
End Function
'''
''' returns all approved users by specified sort
'''
''' if true, return approved users
param>
''' description of sort
''' A List of type MembershipUserWrapper
'''
_
Public Shared Function GetMembers(ByVal approvalStatus As Boolean,
ByVal sortData As String) As List(Of MembershipUserWrapper)
If approvalStatus =3D True Then
Return GetMembers(True, False, Nothing, sortData)
Else
Return GetMembers(False, True, Nothing, sortData)
End If
End Function
'''
''' Return a collection of MembershipUserWrapper's based on criteria
passed in as parameters
'''
''' returns all users with
approval set to true
''' return all users with
approval set to false
''' return based on username (overrides
approval above)
''' sort parameter
''' Returns a Collection of Users (as recommended by
FxCop)
'''
_
Public Shared Function GetMembers(ByVal returnAllApprovedUsers As
Boolean, ByVal returnAllNotApprovedUsers As Boolean, ByVal
usernameToFind As String, ByVal sortData As String) As List(Of
MembershipUserWrapper)
Dim memberList As List(Of MembershipUserWrapper) =3D New List(Of
MembershipUserWrapper)()
' See if we are looking for just one user
If usernameToFind IsNot Nothing Then
Dim mu As MembershipUser =3D Membership.GetUser(usernameToFind)
If mu IsNot Nothing Then
Dim md As New MembershipUserWrapper(mu)
memberList.Add(md)
End If
Else
Dim muc As MembershipUserCollection =3D Membership.GetAllUsers()
For Each mu As MembershipUser In muc
If (returnAllApprovedUsers =3D True AndAlso mu.IsApproved =3D True)
OrElse (returnAllNotApprovedUsers =3D True AndAlso mu.IsApproved =3D
False) Then
Dim md As New MembershipUserWrapper(mu)
memberList.Add(md)
End If
Next mu
If sortData Is Nothing Then
sortData =3D "UserName"
End If
If sortData.Length =3D 0 Then
sortData =3D "UserName"
End If
' Make a special version of sortData for the switch statement so
that whether or not the
' DESC is appended to the string sortData, it will switch on the
base of that string.
Dim sortDataBase As String =3D sortData ' init and assume there is
not DESC appended to sortData
Dim descString As String =3D " DESC"
If sortData.EndsWith(descString) Then
sortDataBase =3D sortData.Substring(0, sortData.Length -
descString.Length)
End If
Dim comparison As Comparison(Of MembershipUserWrapper) =3D Nothing
Select Case sortDataBase
Case "UserName"
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod1)
Case "Email"
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod2)
Case "CreationDate"
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod3)
Case "IsApproved"
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod4)
Case "IsOnline"
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod5)
Case "LastLoginDate"
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod6)
Case Else
comparison =3D New Comparison(Of MembershipUserWrapper)(AddressOf
AnonymousMethod7)
End Select
If sortData.EndsWith("DESC") Then
memberList.Sort(comparison)
memberList.Reverse()
Else
memberList.Sort(comparison)
End If
End If
' FxCopy will give us a warning about returning a List rather than
a Collection.
' We could copy the data, but not worth the trouble.
Return memberList
End Function
Private Shared Function AnonymousMethod1(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Integer
Return lhs.UserName.CompareTo(rhs.UserName)
End Function
Private Shared Function AnonymousMethod2(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Integer
If lhs.Email Is Nothing Or rhs.Email Is Nothing Then
Return 0
Else
Return lhs.Email.CompareTo(rhs.Email)
End If
End Function
Private Shared Function AnonymousMethod3(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.CreationDate.CompareTo(rhs.CreationDate)
End Function
Private Shared Function AnonymousMethod4(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.IsApproved.CompareTo(rhs.IsApproved)
End Function
Private Shared Function AnonymousMethod5(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.IsOnline.CompareTo(rhs.IsOnline)
End Function
Private Shared Function AnonymousMethod6(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.LastLoginDate.CompareTo(rhs.LastLoginDate)
End Function
Private Shared Function AnonymousMethod7(ByVal lhs As
MembershipUserWrapper, ByVal rhs As MembershipUserWrapper) As Object
Return lhs.UserName.CompareTo(rhs.UserName)
End Function
End Class
End Namespace
==================== =====3D=
==================== =====3D=
=3Dend
file===================3 D=====3D=
==================== =====3D=
===========3D
==================== =====3D=
========MembershipUserWrapper.vb
file===================3 D=====3D=
==================== =====3D=
============
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic
Imports System.ComponentModel
Namespace MembershipUtilities
'''
''' Summary description for MembershipUserWrapper
''' This class is inherited from MembershipUser
''' Using the sytax public class ClassName (..) :
base(initializers...) allows for calling the
''' contstructor of the base class. In this case MembershipUser.
'''
'''
Public Class MembershipUserWrapper
Inherits MembershipUser
'''
''' This constructor is used to create a MembershipUserWrapper
from a MembershipUser object. MembershipUser is a default type used
''' in the Membership API provided with ASP.NET 2.0
'''
''' MembershipUser object
Public Sub New(ByVal mu As MembershipUser)
MyBase.New(mu.ProviderName, mu.UserName,
mu.ProviderUserKey, mu.Email, mu.PasswordQuestion, mu.Comment, _
mu.IsApproved, mu.IsLockedOut, mu.CreationDate,
mu.LastLoginDate, mu.LastActivityDate, mu.LastPasswordChangedDate, _
mu.LastLockoutDate)
End Sub
'''
''' This calls the base class UserName property. It is here so
we can tag
''' this property as the primary key so that datakeynames
attribute gets set in the data control.
'''
'''
_
Public Overloads Overrides ReadOnly Property UserName() As
String
Get
Return MyBase.UserName
End Get
End Property
'''
''' This constructor is used to create a MembershipUserWrapper
from individual parameters values.
''' For details of what each parameter means, see the
Microsoft Membership class.
'''
''' Passes to MembershipUser.comment
param>
''' Passes to
MembershipUser.creationDate
''' Passes to MembershipUser.email
''' Passes to
MembershipUser.isApproved
''' Passes to
MembershipUser.lastActivityDate
''' Passes to
MembershipUser.lastLoginDate
''' Passes to
MembershipUser.passwordQuestion
''' Passes to
MembershipUser.providerUserKey
''' Passes to MembershipUser.userName
param>
''' Passes to
MembershipUser.lastLockoutDate
''' Passes to
MembershipUser.providerName
'''
Public Sub New(ByVal comment As String, ByVal creationDate As
DateTime, ByVal email As String, ByVal isApproved As Boolean, ByVal
lastActivityDate As DateTime, ByVal lastLoginDate As DateTime, _
ByVal passwordQuestion As String, ByVal providerUserKey As
Object, ByVal userName As String, ByVal lastLockoutDate As DateTime,
ByVal providerName As String)
' This calls a constructor of MembershipUser automatically
because of the base reference above
MyBase.New(providerName, userName, providerUserKey, email,
passwordQuestion, comment, _
isApproved, False, creationDate, lastLoginDate,
lastActivityDate, DateTime.Now, _
lastLockoutDate)
End Sub
End Class
End Namespace
==================== =====3D=
============end
file===================3 D=====3D=
==================== =====3D=
==================== ==
please try to provide me the solution ASAP. Thanks!