home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETJSharp / VJREDIST.EXE / jsredist.msi / Binary.BIN_File_138137 < prev    next >
Encoding:
Text File  |  2003-03-19  |  5.0 KB  |  162 lines

  1. REM
  2. REM Script to the compiler entry and the httpHandler entries
  3. REM
  4. REM Partha Pratim Das 01/29/2002
  5. REM (c) Microsoft Corporation
  6. REM
  7. REM Arguments passed as "[DEBUG]|[REMOVE]|[MSNETINSTALLDIR]|[LANGUAGE]|[EXTENSION]|[TYPE]|"
  8. REM
  9. REM 
  10. REM <compiler 
  11. REM   language="VJ#" 
  12. REM   extension=".jsl" 
  13. REM   type="Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=dd212db978203033"
  14. REM />
  15. REM
  16. REM <add verb="*" path="*.jsl" type="System.Web.HttpForbiddenHandler"/>
  17. REM <add verb="*" path="*.java" type="System.Web.HttpForbiddenHandler"/>
  18. REM <add verb="*" path="*.vjsproj" type="System.Web.HttpForbiddenHandler"/>
  19. REM
  20.  
  21.  
  22. REM Initializations...
  23. ' Please declare before you use
  24. Option Explicit
  25. ' Ignore all errors
  26. On Error Resume Next
  27.  
  28.  
  29. REM Parse the arguments
  30. 'For private testing
  31. '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|"
  32. ' This is the actual stuff
  33. Dim arg : arg = Session.Property( "CustomActionData" )
  34. Dim argv : argv = Split( arg, "|", -1, 1 )
  35.  
  36. ' Set the debug flag
  37. Dim debug
  38. If ( StrComp( argv(0), "0" ) = 0 ) Then
  39.     debug = False
  40. Else
  41.     debug = True
  42. End If
  43.  
  44. ' Install/Repair or Uninstall
  45. Dim Remove
  46. If ( StrComp( argv(1), "1", vbTextCompare ) = 0 ) Then
  47.     Remove = True
  48. Else
  49.     Remove = False
  50. End If
  51.  
  52. ' URT Install dir
  53. Dim URTInstallDir : URTInstallDir = argv(2)
  54.  
  55. ' Language
  56. Dim Lang : Lang = argv(3)
  57.  
  58. ' Extension
  59. Dim Extn : Extn = argv(4)
  60.  
  61. ' Type
  62. Dim TypeStr : TypeStr = argv(5)
  63.  
  64. ' The machine.config file
  65. Dim configFileName : configFileName = URTInstallDir & "CONFIG\" & "machine.config"
  66.  
  67.  
  68. REM A check point
  69. Dim Action : Action = "Install"
  70. If debug Then
  71.     If Remove Then Action = "Uninstall"
  72.     MsgBox "Action : " & Action & vbCrLf &_
  73.         "Config File Name : " & configFileName & vbCrLf &_
  74.         "Language : " & Lang & vbCrlf &_
  75.         "Extension : " & Extn & vbCrlf &_
  76.         "Type : " & TypeStr
  77. End If
  78.  
  79.  
  80. REM Start the real work
  81. ' Initialize XML Processing 
  82. Dim xml : Set xml = CreateObject( "MSXML.DOMDocument" )
  83. xml.async = False
  84. xml.validateOnParse = False
  85. Dim ret : ret = xml.load( configFileName )
  86. If Not ret Then
  87.  
  88.     ' Parse error
  89.     If debug Then
  90.         MsgBox "Parse error : " & configFileName
  91.     End If
  92.  
  93. Else
  94.  
  95.     Dim root : Set root = xml.documentElement
  96.     Dim compilers : Set compilers = root.selectSingleNode( "//compilers" )
  97.     Dim httpHandlers : Set httpHandlers = root.selectSingleNode( "//httpHandlers" )
  98.     Dim oldVjsCompiler, newVjsCompiler : Set oldVjsCompiler = root.selectSingleNode( "//compiler[@extension = '.jsl']" )
  99.     
  100.     If debug Then MsgBox compilers.xml
  101.     If Not Remove Then
  102.  
  103.         REM Either Install/Repair or Uninstall
  104.         ' Delete the node... ignore the error when the node doesnt exist
  105.         On Error Resume Next    'Ignore the error
  106.         compilers.removeChild( oldVjsCompiler )
  107.         On Error Goto 0         'Dont ignore the errors anymore
  108.         ' Create the new compiler element
  109.         Set newVjsCompiler = xml.createElement( "compiler" )
  110.         newVjsCompiler.setAttribute "language", Lang
  111.         newVjsCompiler.setAttribute "extension", Extn
  112.         newVjsCompiler.setAttribute "type", TypeStr
  113.         compilers.appendChild newVjsCompiler
  114.         
  115.         ' Refresh each handler - put the handler before the first element in the list
  116.         RefreshHttpHandler httpHandlers, "*.jsl", true
  117.         RefreshHttpHandler httpHandlers, "*.java", true
  118.         RefreshHttpHandler httpHandlers, "*.vjsproj", true
  119.         
  120.     Else
  121.  
  122.         REM Remove
  123.         ' Delete the j# compiler node... ignore the error when the node doesnt exist
  124.         On Error Resume Next    'Ignore the error
  125.         compilers.removeChild( oldVjsCompiler )
  126.         On Error Goto 0         'Dont ignore the errors anymore
  127.         
  128.         ' Delete remove the httpHandler entries
  129.         RefreshHttpHandler httpHandlers, "*.jsl", false
  130.         RefreshHttpHandler httpHandlers, "*.java", false
  131.         RefreshHttpHandler httpHandlers, "*.vjsproj", false
  132.  
  133.     End If
  134.  
  135.     If debug Then MsgBox compilers.xml
  136.     ' Make the changes persistent
  137.     xml.save( configFileName )
  138.  
  139. End If
  140.  
  141. Sub RefreshHttpHandler( ByRef httpHandlers, extn, refresh )
  142.  
  143.     Dim oldExtn, newExtn : Set oldExtn = httpHandlers.selectSingleNode( "//add[@path = '" & extn & "']" )
  144.     
  145.     ' Delete the httphandler for the extension, ignore the error if it doesnt exist
  146.     On Error Resume Next    'Ignore the error
  147.     httpHandlers.removeChild( oldExtn )
  148.     On Error Goto 0         'Dont ignore the errors anymore
  149.     
  150.     ' If it is repair/remove, then add the handlers
  151.     If Refresh = true Then
  152.        
  153.         Set newExtn = xml.createElement( "add" )
  154.         newExtn.setAttribute "verb", "*"
  155.         newExtn.setAttribute "path", extn
  156.         newExtn.setAttribute "type", "System.Web.HttpForbiddenHandler"
  157.         httpHandlers.insertBefore newExtn, httpHandlers.childNodes.item( 0 )
  158.        
  159.     End If
  160.  
  161. End Sub 
  162.