home *** CD-ROM | disk | FTP | other *** search
- REM
- REM Script to the compiler entry and the httpHandler entries
- REM
- REM Partha Pratim Das 01/29/2002
- REM (c) Microsoft Corporation
- REM
- REM Arguments passed as "[DEBUG]|[REMOVE]|[MSNETINSTALLDIR]|[LANGUAGE]|[EXTENSION]|[TYPE]|"
- REM
- REM
- REM <compiler
- REM language="VJ#"
- REM extension=".jsl"
- REM type="Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=dd212db978203033"
- REM />
- REM
- REM <add verb="*" path="*.jsl" type="System.Web.HttpForbiddenHandler"/>
- REM <add verb="*" path="*.java" type="System.Web.HttpForbiddenHandler"/>
- REM <add verb="*" path="*.vjsproj" type="System.Web.HttpForbiddenHandler"/>
- REM
-
-
- REM Initializations...
- ' Please declare before you use
- Option Explicit
- ' Ignore all errors
- On Error Resume Next
-
-
- REM Parse the arguments
- 'For private testing
- 'Dim arg : arg = "1|1|\\partha-dev\c\m.c\|VJ#|.jsl|Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a|"
- ' This is the actual stuff
- Dim arg : arg = Session.Property( "CustomActionData" )
- Dim argv : argv = Split( arg, "|", -1, 1 )
-
- ' Set the debug flag
- Dim debug
- If ( StrComp( argv(0), "0" ) = 0 ) Then
- debug = False
- Else
- debug = True
- End If
-
- ' Install/Repair or Uninstall
- Dim Remove
- If ( StrComp( argv(1), "1", vbTextCompare ) = 0 ) Then
- Remove = True
- Else
- Remove = False
- End If
-
- ' URT Install dir
- Dim URTInstallDir : URTInstallDir = argv(2)
-
- ' Language
- Dim Lang : Lang = argv(3)
-
- ' Extension
- Dim Extn : Extn = argv(4)
-
- ' Type
- Dim TypeStr : TypeStr = argv(5)
-
- ' The machine.config file
- Dim configFileName : configFileName = URTInstallDir & "CONFIG\" & "machine.config"
-
-
- REM A check point
- Dim Action : Action = "Install"
- If debug Then
- If Remove Then Action = "Uninstall"
- MsgBox "Action : " & Action & vbCrLf &_
- "Config File Name : " & configFileName & vbCrLf &_
- "Language : " & Lang & vbCrlf &_
- "Extension : " & Extn & vbCrlf &_
- "Type : " & TypeStr
- End If
-
-
- REM Start the real work
- ' Initialize XML Processing
- Dim xml : Set xml = CreateObject( "MSXML.DOMDocument" )
- xml.async = False
- xml.validateOnParse = False
- Dim ret : ret = xml.load( configFileName )
- If Not ret Then
-
- ' Parse error
- If debug Then
- MsgBox "Parse error : " & configFileName
- End If
-
- Else
-
- Dim root : Set root = xml.documentElement
- Dim compilers : Set compilers = root.selectSingleNode( "//compilers" )
- Dim httpHandlers : Set httpHandlers = root.selectSingleNode( "//httpHandlers" )
- Dim oldVjsCompiler, newVjsCompiler : Set oldVjsCompiler = root.selectSingleNode( "//compiler[@extension = '.jsl']" )
-
- If debug Then MsgBox compilers.xml
- If Not Remove Then
-
- REM Either Install/Repair or Uninstall
- ' Delete the node... ignore the error when the node doesnt exist
- On Error Resume Next 'Ignore the error
- compilers.removeChild( oldVjsCompiler )
- On Error Goto 0 'Dont ignore the errors anymore
- ' Create the new compiler element
- Set newVjsCompiler = xml.createElement( "compiler" )
- newVjsCompiler.setAttribute "language", Lang
- newVjsCompiler.setAttribute "extension", Extn
- newVjsCompiler.setAttribute "type", TypeStr
- compilers.appendChild newVjsCompiler
-
- ' Refresh each handler - put the handler before the first element in the list
- RefreshHttpHandler httpHandlers, "*.jsl", true
- RefreshHttpHandler httpHandlers, "*.java", true
- RefreshHttpHandler httpHandlers, "*.vjsproj", true
-
- Else
-
- REM Remove
- ' Delete the j# compiler node... ignore the error when the node doesnt exist
- On Error Resume Next 'Ignore the error
- compilers.removeChild( oldVjsCompiler )
- On Error Goto 0 'Dont ignore the errors anymore
-
- ' Delete remove the httpHandler entries
- RefreshHttpHandler httpHandlers, "*.jsl", false
- RefreshHttpHandler httpHandlers, "*.java", false
- RefreshHttpHandler httpHandlers, "*.vjsproj", false
-
- End If
-
- If debug Then MsgBox compilers.xml
- ' Make the changes persistent
- xml.save( configFileName )
-
- End If
-
- Sub RefreshHttpHandler( ByRef httpHandlers, extn, refresh )
-
- Dim oldExtn, newExtn : Set oldExtn = httpHandlers.selectSingleNode( "//add[@path = '" & extn & "']" )
-
- ' Delete the httphandler for the extension, ignore the error if it doesnt exist
- On Error Resume Next 'Ignore the error
- httpHandlers.removeChild( oldExtn )
- On Error Goto 0 'Dont ignore the errors anymore
-
- ' If it is repair/remove, then add the handlers
- If Refresh = true Then
-
- Set newExtn = xml.createElement( "add" )
- newExtn.setAttribute "verb", "*"
- newExtn.setAttribute "path", extn
- newExtn.setAttribute "type", "System.Web.HttpForbiddenHandler"
- httpHandlers.insertBefore newExtn, httpHandlers.childNodes.item( 0 )
-
- End If
-
- End Sub
-