Novato VS 2005 VB a c#
Publicado por SERGIO ANTONIO (2 intervenciones) el 15/07/2008 03:37:52
No se si alguien puede ayudarme, estoy tratando de comprender que hace este código para traspasarlo a c#, la verdad conozco y entiendo los conceptos de herencia y polimorfismo, pero nunca los había utilizado personalmente, hasta el momento solo realizaba analisis no programaba,
Se les agradece, si pueden ayudarme
Aqui esta el código
Option Explicit On
Imports System
Imports System.Collections.Specialized
Imports System.Security.Cryptography
Imports System.Text
Imports System.Web
Imports APPPROYECTOVEN.AplicacionesCompartidas.Criptografia
Public Class SecureQueryString
Inherits NameValueCollection
Public Sub New()
End Sub
Public Sub New(ByVal encryptedString As String)
deserialize(decrypt(encryptedString.Replace(" ", "+")))
End Sub
Public ReadOnly Property EncryptedString() As String
Get
Return HttpUtility.UrlEncode(encrypt(serialize()))
End Get
End Property
Public Shadows ReadOnly Property ToString()
Get
Return EncryptedString
End Get
End Property
Private Sub deserialize(ByVal decryptedQueryString As String)
Dim nameValuePairs As String() = decryptedQueryString.Split("&")
Dim i As Integer
For i = 0 To (nameValuePairs.Length - 1)
Dim nameValue As String() = nameValuePairs(i).Split("=")
If (nameValue.Length = 2) Then
Me.Add(nameValue(0), nameValue(1))
End If
Next i
End Sub
Private Function serialize() As String
Dim sb As StringBuilder = New StringBuilder()
Dim key As String
For Each key In Me.AllKeys
sb.Append(key)
sb.Append("=")
sb.Append(Me(key))
sb.Append("&")
Next
Return sb.ToString()
End Function
End Class
Se les agradece, si pueden ayudarme
Aqui esta el código
Option Explicit On
Imports System
Imports System.Collections.Specialized
Imports System.Security.Cryptography
Imports System.Text
Imports System.Web
Imports APPPROYECTOVEN.AplicacionesCompartidas.Criptografia
Public Class SecureQueryString
Inherits NameValueCollection
Public Sub New()
End Sub
Public Sub New(ByVal encryptedString As String)
deserialize(decrypt(encryptedString.Replace(" ", "+")))
End Sub
Public ReadOnly Property EncryptedString() As String
Get
Return HttpUtility.UrlEncode(encrypt(serialize()))
End Get
End Property
Public Shadows ReadOnly Property ToString()
Get
Return EncryptedString
End Get
End Property
Private Sub deserialize(ByVal decryptedQueryString As String)
Dim nameValuePairs As String() = decryptedQueryString.Split("&")
Dim i As Integer
For i = 0 To (nameValuePairs.Length - 1)
Dim nameValue As String() = nameValuePairs(i).Split("=")
If (nameValue.Length = 2) Then
Me.Add(nameValue(0), nameValue(1))
End If
Next i
End Sub
Private Function serialize() As String
Dim sb As StringBuilder = New StringBuilder()
Dim key As String
For Each key In Me.AllKeys
sb.Append(key)
sb.Append("=")
sb.Append(Me(key))
sb.Append("&")
Next
Return sb.ToString()
End Function
End Class
Valora esta pregunta


0