Hola estoy experimentando con algunos aspectos de los servicios web y en un
articulo tecnico me viene un codigo q no esta en visual basic y me ruego es
si alguien me lo podria pasar a c#, muchas gracias
aqui esta el codigo
Public Overrides Sub Install(ByVal stateSaver As _
System.Collections.IDictionary)
' Gets the parameter passed across in the CustomActionData.
Dim installlog As New System.IO.StreamWriter("Installation.log")
installlog.AutoFlush = True
Try
Dim ProvidedName As String = _
Me.Context.Parameters.Item("ServerName")
Dim SvcName As String = Me.Context.Parameters.Item("ServiceName")
installlog.WriteLine("Starting Edit of the config file")
If ProvidedName = "" Or SvcName = "" Then
Throw New InstallException("No arguments specified")
End If
' Uses reflection to find the location of the config file.
Dim Asm As System.Reflection.Assembly = _
System.Reflection.Assembly.GetExecutingAssembly
Dim strConfigLoc As String
strConfigLoc = Asm.Location
Dim strTemp As String
strTemp = strConfigLoc
strTemp = strTemp.Remove(strTemp.LastIndexOf("\"), Len(strTemp) _
- strTemp.LastIndexOf("\"))
strTemp = strTemp.Remove(strTemp.LastIndexOf("\"), Len(strTemp) _
- strTemp.LastIndexOf("\"))
Dim FileInfo As System.IO.FileInfo = New _
System.IO.FileInfo(strTemp & "\web.config")
installlog.WriteLine("File info: " & strTemp)
If Not FileInfo.Exists Then
Throw New InstallException("Missing config file")
End If
' Loads the config file into the XML DOM.
Dim XmlDocument As New System.Xml.XmlDocument()
XmlDocument.Load(FileInfo.FullName)
' Finds the right node and change it to the new value.
Dim Node As System.Xml.XmlNode
Dim FoundIt As Boolean = False
For Each Node In
XmlDocument.Item("configuration").Item("appSettings")
' Skips any comments.
If Node.Name = "add" Then
If Node.Attributes.GetNamedItem("key").Value = _
"appname.servername.service" Then
' Note that "Service1.asmx" should be replaced with the
' actual name of the XML Web service file.
Node.Attributes.GetNamedItem("value").Value = _
"http://" & ProvidedName & "/" & SvcName & "/Service1.asmx"
FoundIt = True
End If
End If
Next Node
If Not FoundIt Then
Throw New InstallException("Config file did not contain a _
ServerName section")
End If
' Writes out the new config file.
XmlDocument.Save(FileInfo.FullName)
Finally
installlog.WriteLine("Ending edit of config file")
installlog.Close()
End Try
End Sub
Leer las respuestas