|
-
Nov 11th, 2003, 02:10 AM
#1
Thread Starter
Addicted Member
quick translation needed ( c# to vb )
hi,
it would be very kind if someone helps me out here, i need this code translated to vb.net.
i understand most of it, like one thing i cant figure out is the " continue" method? whats the equilivent of that in vb.net?!!!
Code:
foreach(XmlNode xnode in section.ChildNodes)
{
if(!(xnode.NodeType == XmlNodeType.Element && xnode.Attributes != null)) continue ;
if(xnode.Attributes["domainlocal"] != null && Convert.ToBoolean(xnode.Attributes["domainlocal"].Value) == false)
{
//host list needs to be mentioned, if domainlocal is false
if(xnode.Attributes["host"] == null) throw new ApplicationException("Configuration Error : For Single Signon Targets that are not local to the domain, a host list must be provided");
_SingleSignonTargetList.Add(new SampleAuthenticationSingleSignonTarget(xnode.Attributes["host"].Value));
}
else
{
if(xnode.Attributes["name"] == null) throw new ApplicationException(" Configuration Error : For Single Signon Targets that are local to the domain, a cookie name must be provided");
if(xnode.Attributes["path"] == null) throw new ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided");
if(xnode.Attributes["persistent"] == null) throw new ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided");
_SingleSignonTargetList.Add(new SampleAuthenticationSingleSignonTarget(xnode.Attributes["name"].Value,xnode.Attributes["path"].Value,Convert.ToBoolean(xnode.Attributes["persistent"].Value)));
}
}
Last edited by persianboy; Nov 11th, 2003 at 11:48 AM.
-
Nov 11th, 2003, 12:05 PM
#2
Lively Member
Umm, ok so far so good. But when you call 'continue', what do you expect it to do? cuz my program can't determine what Continue does. does it continue with the sub. if it does, are there any other tasks used with continue before heading on to the next line of code?
Last edited by Danny J; Nov 11th, 2003 at 12:20 PM.
DannyJoumaa
Advanced VB6 Programmer
Intermediate-Advanced VB .NET Programmer
Intermediate C# Programmer
Intermediate Win32 Developer
Beginner Mac OS X Developer
Contact: [email protected]
Favorite Sayings:
"Every time you open your mouth, you prove your an idiot."
"God is a programmer. Satan is a bug. Life is debugging."
-
Nov 11th, 2003, 12:30 PM
#3
yay gay
continue is not a method, as stated in MSDN lib:
The continue statement passes control to the next iteration of the enclosing iteration statement in which it appears.
which means that if you are in a loop or something like that it stops the execution flow there and continues in the next FOR
\m/  \m/
-
Nov 11th, 2003, 12:45 PM
#4
Lively Member
If the code below doesn't function the way it did in CS, please contact me immediatly, and tell me what is going wrong so I can tweak my application.
VB Code:
Public Sub TranslatedOutput()
'Code translated with Danny J's .NET Code Converter ALPHA created by Danny Joumaa
Dim xnode As Xml.XmlNode
For Each xnode In xnode.ChildNodes
'TODO: Method 'continue' could not be recodnized. User suggested new code.
If Not (xnode.NodeType = Xml.XmlNodeType.Element And xnode.Attributes Is Nothing) Then Exit Sub
If (xnode.Attributes("domainlocal") Is Nothing & Convert.ToBoolean(xnode.Attributes("domainlocal").Value)) = False Then
'host list needs to be mentioned, if domainlocal is false
If (xnode.Attributes("host") Is Nothing) Then Throw New ApplicationException(" Configuration Error : For Single Signon Targets that that are local to the domain, a cookie name must be provided")
If (xnode.Attributes("path") Is Nothing) Then Throw New ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided")
If (xnode.Attributes("persistent") Is Nothing) Then Throw New ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided")
'TODO: The code below could not be translated. Please translate this code manually.
'_SingleSignonTargetList.Add(new SampleAuthenticationSingleSignonTarget(xnode.Attributes["name"].Value,xnode.Attributes["path"].Value,Convert.ToBoolean(xnode.Attributes["persistent"].Value)));
End If
Next
End Sub
Cheers!
DannyJoumaa
Advanced VB6 Programmer
Intermediate-Advanced VB .NET Programmer
Intermediate C# Programmer
Intermediate Win32 Developer
Beginner Mac OS X Developer
Contact: [email protected]
Favorite Sayings:
"Every time you open your mouth, you prove your an idiot."
"God is a programmer. Satan is a bug. Life is debugging."
-
Nov 11th, 2003, 03:08 PM
#5
Thread Starter
Addicted Member
i dont have vs around to test it, but it seems its not correct
Code:
Public Sub TranslatedOutput()
Dim xnode As Xml.XmlNode
For Each xnode In xnode.ChildNodes
' i dont think what the continue does is to exit the for, i think it should move on to the next xnode without processing the code under it , tell me if i'm wrong?? ( and you missed a not too )
If Not (xnode.NodeType = Xml.XmlNodeType.Element And Not xnode.Attributes Is Nothing) Then Exit Sub
If (xnode.Attributes("domainlocal") Is Nothing & Convert.ToBoolean(xnode.Attributes("domainlocal").Value)) = False Then
'host list needs to be mentioned, if domainlocal is false
If (xnode.Attributes("host") Is Nothing) Then Throw New ApplicationException(" Configuration Error : For Single Signon Targets that that are local to the domain, a cookie name must be provided")
If (xnode.Attributes("path") Is Nothing) Then Throw New ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided")
If (xnode.Attributes("persistent") Is Nothing) Then Throw New ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided")
'TODO: The code below could not be translated. Please translate this code manually.
'_SingleSignonTargetList.Add(new SampleAuthenticationSingleSignonTarget(xnode.Attributes["name"].Value,xnode.Attributes["path"].Value,Convert.ToBoolean(xnode.Attributes["persistent"].Value)));
End If
Next
End Sub
]
so the main thing here is the continue, how to translate that?
-
Nov 11th, 2003, 03:13 PM
#6
yay gay
of course it can't be correct, he did put "exit sub" in the place of a "continue" that are completly different things
\m/  \m/
-
Nov 11th, 2003, 03:18 PM
#7
I wonder how many charact
Originally posted by PT Exorcist
of course it can't be correct, he did put "exit sub" in the place of a "continue" that are completly different things
LMAO, Ah the perils of using an automated C# translator
-
Nov 11th, 2003, 04:07 PM
#8
Thread Starter
Addicted Member
Code:
Dim xnode As XmlNode
For Each xnode In section.ChildNodes
If xnode.NodeType = XmlNodeType.Element And Not xnode.Attributes Is Nothing Then
If Not xnode.Attributes("domainlocal") Is Nothing And Convert.ToBoolean(xnode.Attributes("domainlocal").Value) = False Then
If xnode.Attributes("host") Is Nothing Then Throw New ApplicationException("Authentication Configuratio Error : For SignOn Targets that are not local to the domain , a host list must be porvided")
_SingleSignOnTargetList.Add(New Authentication.AuthenticationSingleSignOnTarget(xnode.Attributes("host").Value))
Else
If xnode.Attributes("name") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are not local to the domain, a host list must be provided")
If xnode.Attributes("path") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided")
If xnode.Attributes("persistent") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided")
_SingleSignOnTargetList.Add(New Authentication.AuthenticationSingleSignOnTarget(xnode.Attributes("name").Value, xnode.Attributes("path").Value, Convert.ToBoolean(xnode.Attributes("persistent").Value)))
End If
End If
Next
is this how it should look like in vb.net?!!!!!!!
( cant test it in code, since i havent finished translating othere related parts )
-
Nov 11th, 2003, 04:18 PM
#9
I wonder how many charact
well, its 100% syntax-correct. Compiler doesn't complain.
-
Nov 11th, 2003, 04:29 PM
#10
Thread Starter
Addicted Member
this continue is whats got me confused a little , maybe this exp will help me figure it out
for a=1 to 3
if a=2 then continue
str &=a
next
lbltext.text=str
so finally is the labels text 13 or 1??
p.s i dont if this is how the syntax of for...next is in C#, anyways thats not the idea of the question
-
Nov 11th, 2003, 04:35 PM
#11
I wonder how many charact
According to the original code posted, I'm guessing it should not process the rest of the for loop if the node is an element. I only say that because, it appears they are trying to catch exceptions, and if its the smallest child node, it would not contain any other nodes:
VB Code:
Dim xnode As XmlNode
For Each xnode In section.ChildNodes
If xnode.NodeType = XmlNodeType.Element And Not xnode.Attributes Is Nothing Then [b]Continue[/b]
If Not xnode.Attributes("domainlocal") Is Nothing And Convert.ToBoolean(xnode.Attributes("domainlocal").Value) = False Then
If xnode.Attributes("host") Is Nothing Then Throw New ApplicationException("Authentication Configuratio Error : For SignOn Targets that are not local to the domain , a host list must be porvided")
_SingleSignOnTargetList.Add(New Authentication.AuthenticationSingleSignOnTarget(xnode.Attributes("host").Value))
Else
If xnode.Attributes("name") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are not local to the domain, a host list must be provided")
If xnode.Attributes("path") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided")
If xnode.Attributes("persistent") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided")
_SingleSignOnTargetList.Add(New Authentication.AuthenticationSingleSignOnTarget(xnode.Attributes("name").Value, xnode.Attributes("path").Value, Convert.ToBoolean(xnode.Attributes("persistent").Value)))
End If
End If
Next
Persian, as far as your example:
VB Code:
for a=1 to 3
if a=2 then continue
str &=a
next
lbltext.text=str
If a=2, then it skips str&=a.
-
Nov 11th, 2003, 04:41 PM
#12
Thread Starter
Addicted Member
so finally this code in c#
Code:
foreach(XmlNode xnode in section.ChildNodes)
{
if(!(xnode.NodeType == XmlNodeType.Element && xnode.Attributes != null)) continue ;
if(xnode.Attributes["domainlocal"] != null && Convert.ToBoolean(xnode.Attributes["domainlocal"].Value) == false)
{
//host list needs to be mentioned, if domainlocal is false
if(xnode.Attributes["host"] == null) throw new ApplicationException("Configuration Error : For Single Signon Targets that are not local to the domain, a host list must be provided");
_SingleSignonTargetList.Add(new SampleAuthenticationSingleSignonTarget(xnode.Attributes["host"].Value));
}
else
{
if(xnode.Attributes["name"] == null) throw new ApplicationException(" Configuration Error : For Single Signon Targets that are local to the domain, a cookie name must be provided");
if(xnode.Attributes["path"] == null) throw new ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided");
if(xnode.Attributes["persistent"] == null) throw new ApplicationException("Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided");
_SingleSignonTargetList.Add(new SampleAuthenticationSingleSignonTarget(xnode.Attributes["name"].Value,xnode.Attributes["path"].Value,Convert.ToBoolean(xnode.Attributes["persistent"].Value)));
}
}
is equil to the code beneath in vb.net
Code:
Dim xnode As XmlNode
For Each xnode In section.ChildNodes
If xnode.NodeType = XmlNodeType.Element And Not xnode.Attributes Is Nothing Then
If Not xnode.Attributes("domainlocal") Is Nothing And Convert.ToBoolean(xnode.Attributes("domainlocal").Value) = False Then
If xnode.Attributes("host") Is Nothing Then Throw New ApplicationException("Authentication Configuratio Error : For SignOn Targets that are not local to the domain , a host list must be porvided")
_SingleSignOnTargetList.Add(New Authentication.AuthenticationSingleSignOnTarget(xnode.Attributes("host").Value))
Else
If xnode.Attributes("name") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are not local to the domain, a host list must be provided")
If xnode.Attributes("path") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are local to the domain, a cookie path must be provided")
If xnode.Attributes("persistent") Is Nothing Then Throw New ApplicationException("Authentication Configuration Error : For Single Signon Targets that are local to the domain, a cookie persistence indicator must be provided")
_SingleSignOnTargetList.Add(New Authentication.AuthenticationSingleSignOnTarget(xnode.Attributes("name").Value, xnode.Attributes("path").Value, Convert.ToBoolean(xnode.Attributes("persistent").Value)))
End If
End If
Next
thanks to all
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|