コード例 #1
0
def compileAssembly(file_name):
    '''
    Helper function compiles a *.cs file.
    '''
    cp = CompilerParameters()
    cp.GenerateExecutable = False
    cp.OutputAssembly = file_name.split(".cs")[0] + ".dll"
    cp.GenerateInMemory = False
    cp.TreatWarningsAsErrors = False
    cp.IncludeDebugInformation = True
    cp.ReferencedAssemblies.Add("IronPython.dll")
    cr = PROVIDER.CompileAssemblyFromFile(cp, file_name)
コード例 #2
0
def compileAssembly(file_name):
    '''
    Helper function compiles a *.cs file.
    '''
    cp = CompilerParameters()
    cp.GenerateExecutable = False
    cp.OutputAssembly = file_name.split(".cs")[0] + ".dll"
    cp.GenerateInMemory = False
    cp.TreatWarningsAsErrors = False
    cp.IncludeDebugInformation = True
    cp.ReferencedAssemblies.Add("IronPython.dll")
    cr = PROVIDER.CompileAssemblyFromFile(cp, file_name)
コード例 #3
0
ファイル: codedom.py プロジェクト: devhawk/devhawk_ipy
def compile(prov, file, references):
  from System.CodeDom.Compiler import CompilerParameters 
  from System.Reflection.Assembly import LoadWithPartialName 
  cp = CompilerParameters()
  cp.GenerateInMemory = True
  for ref in references:
    a = LoadWithPartialName(ref)
    cp.ReferencedAssemblies.Add(a.Location)
  cr = prov.CompileAssemblyFromFile(cp, file)
  if cr.Errors.Count > 0:
    raise Exception(cr.Errors)
  return cr.CompiledAssembly
コード例 #4
0
def CreateWebServiceFromWsdl(wsdl):
    'convert the WSDL into an assembly containing the web service proxy classes'
    # generate codeDom from wsdl
    sd = ServiceDescription.Read(MemoryStream(wsdl))
    importer = ServiceDescriptionImporter()
    importer.ServiceDescriptions.Add(sd)

    codeCompileUnit = CodeCompileUnit()
    codeNamespace = CodeNamespace("")
    codeCompileUnit.Namespaces.Add(codeNamespace)
    importer.CodeGenerationOptions = (CodeGenerationOptions.GenerateNewAsync
        | CodeGenerationOptions.GenerateOldAsync)
    importer.Import(codeNamespace, codeCompileUnit)

    # compile CodeDom into an assembly
    provider = CodeDomProvider.CreateProvider("CS")
    compilerParams = CompilerParameters()
    compilerParams.GenerateInMemory = True
    compilerParams.IncludeDebugInformation = False
    results = provider.CompileAssemblyFromDom(compilerParams, codeCompileUnit)
    generatedAssembly = results.CompiledAssembly

    return generatedAssembly
コード例 #5
0
def CreateWebServiceFromWsdl(wsdl):
    'convert the WSDL into an assembly containing the web service proxy classes'
    # generate codeDom from wsdl
    sd = ServiceDescription.Read(MemoryStream(wsdl))
    importer = ServiceDescriptionImporter()
    importer.ServiceDescriptions.Add(sd)

    codeCompileUnit = CodeCompileUnit()
    codeNamespace = CodeNamespace("")
    codeCompileUnit.Namespaces.Add(codeNamespace)
    importer.CodeGenerationOptions = (CodeGenerationOptions.GenerateNewAsync
                                      | CodeGenerationOptions.GenerateOldAsync)
    importer.Import(codeNamespace, codeCompileUnit)

    # compile CodeDom into an assembly
    provider = CodeDomProvider.CreateProvider("CS")
    compilerParams = CompilerParameters()
    compilerParams.GenerateInMemory = True
    compilerParams.IncludeDebugInformation = False
    results = provider.CompileAssemblyFromDom(compilerParams, codeCompileUnit)
    generatedAssembly = results.CompiledAssembly

    return generatedAssembly