当前位置: 首页>>代码示例>>C#>>正文


C# VsaEngine.SetOption方法代码示例

本文整理汇总了C#中Microsoft.JScript.Vsa.VsaEngine.SetOption方法的典型用法代码示例。如果您正苦于以下问题:C# VsaEngine.SetOption方法的具体用法?C# VsaEngine.SetOption怎么用?C# VsaEngine.SetOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.JScript.Vsa.VsaEngine的用法示例。


在下文中一共展示了VsaEngine.SetOption方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: JScriptEngine

        public JScriptEngine(object scriptGlobal)
            : base(scriptGlobal)
        {
            engine = new Microsoft.JScript.Vsa.VsaEngine();
              engine.RootMoniker = "sharpvectors://jsengine/" + counter++;
              engine.Site = this;
              engine.InitNew();
              engine.RootNamespace = "SharpVectors.Scripting";
              engine.GenerateDebugInfo = false;
              engine.RevokeCache();
              engine.SetOption("Fast", false);

              items = engine.Items;
              Assembly asm = typeof(SharpVectors.Scripting.JScriptEngine).Assembly;
              IVsaReferenceItem refItem = (IVsaReferenceItem)items.CreateItem(asm.Location, VsaItemType.Reference, VsaItemFlag.None);
              refItem.AssemblyName = asm.Location;
        }
开发者ID:codebutler,项目名称:savagesvg,代码行数:17,代码来源:JScriptEngine.cs

示例2: ParseCompilerOptions


//.........这里部分代码省略.........

                        case 'P':
                        case 'p':
                            goto Label_0506;

                        case 'R':
                        case 'r':
                            goto Label_0631;

                        case 'T':
                        case 't':
                            goto Label_06AD;

                        case 'U':
                        case 'u':
                            goto Label_07C8;

                        case 'V':
                        case 'v':
                            goto Label_07F3;

                        case 'W':
                        case 'w':
                            goto Label_0838;
                    }
                }
                goto Label_09B4;
            Label_01DE:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "autoref");
                if (obj2 == null)
                {
                    goto Label_09B4;
                }
                engine.SetOption("autoref", obj2);
                if (builder != null)
                {
                    builder.Append(str4);
                    builder.Append(" ");
                }
                goto Label_09C7;
            Label_0223:
                if (CmdLineOptionParser.IsArgumentOption(option, "codepage") == null)
                {
                    goto Label_09B4;
                }
                throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/codepage:<id>", engine.ErrorCultureInfo);
            Label_024E:
                obj2 = CmdLineOptionParser.IsBooleanOption(option, "debug");
                if (obj2 != null)
                {
                    engine.GenerateDebugInfo = (bool) obj2;
                    if (builder != null)
                    {
                        builder.Append(str4);
                        builder.Append(" ");
                    }
                }
                else
                {
                    obj2 = CmdLineOptionParser.IsArgumentOption(option, "d", "define");
                    if (obj2 == null)
                    {
                        goto Label_09B4;
                    }
                    this.GetAllDefines((string) obj2, defines, engine);
                    if (builder != null)
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:67,代码来源:JSInProcCompiler.cs

示例3: CreateAndInitEngine

 private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output)
 {
     VsaEngine engine = new VsaEngine(true);
     VsaSite site = new VsaSite(output);
     engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site);
     this.ValidateOptions(options, engine);
     engine.GenerateDebugInfo = options.IncludeDebugInformation;
     engine.SetOption("referenceLoaderAPI", "LoadFile");
     engine.SetOption("fast", true);
     engine.SetOption("print", false);
     engine.SetOption("VersionSafe", false);
     engine.SetOption("output", options.OutputAssembly);
     if (options.GenerateExecutable)
     {
         engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication);
     }
     else
     {
         engine.SetOption("PEFileKind", PEFileKinds.Dll);
     }
     site.treatWarningsAsErrors = options.TreatWarningsAsErrors;
     engine.SetOption("warnaserror", options.TreatWarningsAsErrors);
     site.warningLevel = options.WarningLevel;
     engine.SetOption("WarningLevel", options.WarningLevel);
     if ((options.Win32Resource != null) && (options.Win32Resource.Length > 0))
     {
         engine.SetOption("win32resource", options.Win32Resource);
     }
     bool flag = false;
     foreach (string str in options.ReferencedAssemblies)
     {
         if (string.Compare(Path.GetFileName(str), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
         {
             flag = true;
         }
         this.AddAssemblyReference(engine, str);
     }
     if (!flag)
     {
         this.AddAssemblyReference(engine, "mscorlib.dll");
     }
     StringCollection args = this.SplitCmdLineArguments(options.CompilerOptions);
     this.ParseCompilerOptions(engine, args, output, options.GenerateExecutable);
     for (int i = 0; i < sourceFiles.Length; i++)
     {
         this.AddSourceFile(engine, sourceFiles[i]);
     }
     return engine;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:49,代码来源:JSInProcCompiler.cs

示例4: ParseCompilerOptions

      private void ParseCompilerOptions(VsaEngine engine, StringCollection args, TextWriter output, bool generateExe){
        // Process compiler options and return command line fragment to complete the partial debug command line
        // that was formed by examining the CompilerParameters structure only.
        string libpath = System.Environment.GetEnvironmentVariable("LIB");
        bool generateWinExe = false;
        Hashtable defines = new Hashtable(10);
        Hashtable resources = new Hashtable(10);
        Hashtable resourceFiles = new Hashtable(10);
        bool targetSpecified = false;

        StringBuilder fullCmdLine = null;
        if (this.debugCommandLine != null)
          fullCmdLine = new StringBuilder(this.debugCommandLine);

        // if '/' separates dir, use '-' as switch
        string cmdLineSwitch = Path.DirectorySeparatorChar == '/' ? "-" : "/" ;

        for (int i = 0, n = args.Count; i < n; i++){
          object argument;
          string option;

          string arg = args[i];
          if (arg == null || arg.Length == 0) continue;

          if (arg[0] == '@')
            throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "@<filename>", engine.ErrorCultureInfo);
         
          // slash ('/') character is a valid filename character on UNIX, so we can't use it as a switch
          if ('-' != arg[0] && ('/' != arg[0] || Path.DirectorySeparatorChar == '/'))
            break;

          option = arg.Substring(1);

          if (option.Length > 0){
            switch (option[0]){
            case '?':
              throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/?", engine.ErrorCultureInfo);
            case 'a':
            case 'A':
              argument = CmdLineOptionParser.IsBooleanOption(option, "autoref");
              if (argument != null){
                engine.SetOption("autoref", argument);
                if (fullCmdLine != null){
                  fullCmdLine.Append(arg);
                  fullCmdLine.Append(" ");
                }
                continue;
              }
              break;
            case 'c':
            case 'C':
              argument = CmdLineOptionParser.IsArgumentOption(option, "codepage");
              if (argument != null)
                throw new CmdLineException(CmdLineError.InvalidForCompilerOptions, "/codepage:<id>", engine.ErrorCultureInfo);
              break;
            case 'd':
            case 'D':
              argument = CmdLineOptionParser.IsBooleanOption(option, "debug");
              if (argument != null){
                engine.GenerateDebugInfo = (bool)argument;
                if (fullCmdLine != null){
                  fullCmdLine.Append(arg);
                  fullCmdLine.Append(" ");
                }
                continue;                        
              }
              argument = CmdLineOptionParser.IsArgumentOption(option, "d", "define");
              if (argument != null){
                this.GetAllDefines((string)argument, defines, engine);
                if (fullCmdLine != null){
                  fullCmdLine.Append(cmdLineSwitch + "d:\"");
                  fullCmdLine.Append((string)argument);
                  fullCmdLine.Append("\" ");
                }
                continue;
              }
              break;
            case 'f':
            case 'F':
              argument = CmdLineOptionParser.IsBooleanOption(option, "fast");
              if (argument != null){
                engine.SetOption("fast", argument);
                if (fullCmdLine != null){
                  fullCmdLine.Append(arg);
                  fullCmdLine.Append(" ");
                }
                continue;
              }
              break;
            case 'l':
            case 'L':
              argument = CmdLineOptionParser.IsArgumentOption(option, "lcid");
              if (argument != null){
                if (((string)argument).Length == 0)
                  throw new CmdLineException(CmdLineError.NoLocaleID, arg, engine.ErrorCultureInfo);
                try{
                  engine.LCID = Int32.Parse((string)argument, CultureInfo.InvariantCulture);
                }catch{
                  throw new CmdLineException(CmdLineError.InvalidLocaleID, (string)argument, engine.ErrorCultureInfo);
                }
//.........这里部分代码省略.........
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:101,代码来源:jsinproccompiler.cs

示例5: CreateAndInitEngine

      private VsaEngine CreateAndInitEngine(CompilerParameters options, string[] sourceFiles, string outputFile, TextWriter output){
        VsaEngine engine = new VsaEngine(true);
        VsaSite site = new VsaSite(output);
        engine.InitVsaEngine("JSCodeGenerator://Microsoft.JScript.Vsa.VsaEngine", site);

        // Ensure that all options are valid; throw a CmdLineException otherwise
        this.ValidateOptions(options, engine);

        // Set options on the engine (equivalent of cmdline args in out-of-proc scenario)
        engine.GenerateDebugInfo = options.IncludeDebugInformation;
        engine.SetOption("referenceLoaderAPI", "LoadFile");
        engine.SetOption("fast", true);
        engine.SetOption("print", false);
        engine.SetOption("VersionSafe", false);
        engine.SetOption("output", options.OutputAssembly);
        if (options.GenerateExecutable)
          engine.SetOption("PEFileKind", PEFileKinds.ConsoleApplication);
        else
          engine.SetOption("PEFileKind", PEFileKinds.Dll);
        site.treatWarningsAsErrors = options.TreatWarningsAsErrors;
        engine.SetOption("warnaserror", options.TreatWarningsAsErrors);
        site.warningLevel = options.WarningLevel;
        engine.SetOption("WarningLevel", options.WarningLevel);
        bool stdLibAdded = false;
        foreach (string assemblyName in options.ReferencedAssemblies){
          if (String.Compare(Path.GetFileName(assemblyName), "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
            stdLibAdded = true;
          this.AddAssemblyReference(engine, assemblyName);
        }
        if (!stdLibAdded)
          this.AddAssemblyReference(engine, "mscorlib.dll");

        // Parse any additional compiler options
        StringCollection compilerOptions = this.SplitCmdLineArguments(options.CompilerOptions);
        this.ParseCompilerOptions(engine, compilerOptions, output, options.GenerateExecutable);

        // Add the source files to the engine (as IVsaCodeItems)
        for (int j = 0; j < sourceFiles.Length; j++)
          this.AddSourceFile(engine, sourceFiles[j]);

        return engine;
      }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:42,代码来源:jsinproccompiler.cs

示例6: Main

		//
		// Entry point
		//
		private static void Main (string [] args) {
			if (args.Length < 1) {
				Usage ();
				Environment.Exit (0);
			}			
			MainDriver (args);
			VsaEngine engine = new VsaEngine ();
			engine.InitVsaEngine ("mjs:com.mono-project", new MonoEngineSite ());
			
			foreach (string asm in references) {
				IVsaReferenceItem item = (IVsaReferenceItem) engine.Items.CreateItem (asm, VsaItemType.Reference, VsaItemFlag.None);
				item.AssemblyName = asm;
			}

			string asm_name = String.Empty;
			
			foreach (Assembly assembly in assemblies) {
				asm_name = assembly.GetName ().FullName;
				IVsaReferenceItem item = (IVsaReferenceItem) engine.Items.CreateItem (asm_name, VsaItemType.Reference, VsaItemFlag.None);
				item.AssemblyName = asm_name;
			}

			foreach (string file in files) {
				IVsaCodeItem item = (IVsaCodeItem) engine.Items.CreateItem (file, VsaItemType.Code, VsaItemFlag.None);
				item.SourceText = GetCodeFromFile (file);
			}
			engine.SetOption ("debug", want_debugging_support);
			engine.SetOption ("link_path", link_paths);
			engine.SetOption ("first_source", first_source);
			engine.SetOption ("assemblies", assemblies);
			engine.SetOption ("out", output_file);
			if (warning_level != -1)
				engine.SetOption ("WarningLevel", warning_level);
			engine.Compile ();
		}
开发者ID:nobled,项目名称:mono,代码行数:38,代码来源:mjs.cs

示例7: Compile

  bool Compile(CompilerOptions options){
    if (this.fPrintTargets)
      Console.WriteLine(Localize("Compiling", options.strOutputFileName));

    VsaEngine engine = new Microsoft.JScript.Vsa.VsaEngine();
    if (null == engine)
      throw new CmdLineException(CmdLineError.CannotCreateEngine, JScriptCompiler.GetCultureInfo());
    engine.InitVsaEngine("JSC://Microsoft.JScript.Vsa.VsaEngine", new EngineSite(options));
    engine.LCID = JScriptCompiler.GetCultureInfo().LCID;
    engine.GenerateDebugInfo = options.fDebug;

    engine.SetOption("ReferenceLoaderAPI", "ReflectionOnlyLoadFrom");
    engine.SetOption("AutoRef", options.autoRef);
    engine.SetOption("fast", options.fFast);
    engine.SetOption("output", options.strOutputFileName);
    engine.SetOption("PEFileKind", options.PEFileKind);
    engine.SetOption("PortableExecutableKind", options.PEKindFlags);
    engine.SetOption("ImageFileMachine", options.PEMachineArchitecture);
    engine.SetOption("print", options.fPrint);
    engine.SetOption("libpath", options.libpath);
    if (options.versionInfo != null)
      engine.SetOption("version", options.versionInfo);
    engine.SetOption("VersionSafe", options.fVersionSafe);
    engine.SetOption("defines", options.Defines);
    engine.SetOption("warnaserror", options.fTreatWarningsAsErrors);
    engine.SetOption("WarningLevel", options.nWarningLevel);
    if (options.ManagedResources.Count > 0)
      engine.SetOption("managedResources", options.ManagedResources.Values);

    bool fStdlibAdded = false;
    bool fWinFormsAdded = false;
    foreach (string assemblyName in options.ImportFileNames){
      AddAssemblyReference(engine, assemblyName);
      string filename = Path.GetFileName(assemblyName);
      if (String.Compare(filename, "mscorlib.dll", StringComparison.OrdinalIgnoreCase) == 0)
        fStdlibAdded = true;
      else if (String.Compare(filename, "System.Windows.Forms.dll", StringComparison.OrdinalIgnoreCase) == 0)
        fWinFormsAdded = true;
    }

    // Only add mscorlib if it hasn't already been added.
    if (!options.fNoStdlib && !fStdlibAdded)
      AddAssemblyReference(engine, "mscorlib.dll");
    // add System.Windows.Forms if target is winexe and it hasn't already been added
    if ((options.PEFileKind == PEFileKinds.WindowApplication) && !options.fNoStdlib && !fWinFormsAdded)
      AddAssemblyReference(engine, "System.Windows.Forms.dll");

    for (int j = 0; j < options.SourceFileNames.Count; j++)
      AddSourceFile(engine, (string)options.SourceFileNames[j], options.codepage);

    bool isCompiled = false;
    try{
      isCompiled = engine.Compile();
    }catch(VsaException e){
      // check for expected errors
      if (e.ErrorCode == VsaError.AssemblyExpected){
        if (e.InnerException != null && e.InnerException is System.BadImageFormatException){
          // the reference was not for an assembly
          CmdLineException cmdLineError = new CmdLineException(CmdLineError.InvalidAssembly, e.Message, JScriptCompiler.GetCultureInfo());
          Console.WriteLine(cmdLineError.Message);
        }else if (e.InnerException != null && (e.InnerException is System.IO.FileNotFoundException || e.InnerException is System.IO.FileLoadException)){
          // the referenced file not valid
          CmdLineException cmdLineError = new CmdLineException(CmdLineError.AssemblyNotFound, e.Message, JScriptCompiler.GetCultureInfo());
          Console.WriteLine(cmdLineError.Message);
        }else{
          CmdLineException cmdLineError = new CmdLineException(CmdLineError.InvalidAssembly, JScriptCompiler.GetCultureInfo());
          Console.WriteLine(cmdLineError.Message);
        }
      }else if (e.ErrorCode == VsaError.SaveCompiledStateFailed){
        CmdLineException cmdLineError = new CmdLineException(CmdLineError.ErrorSavingCompiledState, e.Message, JScriptCompiler.GetCultureInfo());
        Console.WriteLine(cmdLineError.Message);
      }else if (e.ErrorCode == VsaError.AssemblyNameInvalid && e.InnerException != null){
        CmdLineException cmdLineError = new CmdLineException(CmdLineError.InvalidCharacters, e.Message, JScriptCompiler.GetCultureInfo());
        Console.WriteLine(cmdLineError.Message);
      }else{
        Console.WriteLine(Localize("INTERNAL COMPILER ERROR"));
        Console.WriteLine(e);
      }
      return false;
    }catch(Exception e){
      Console.WriteLine(Localize("INTERNAL COMPILER ERROR"));
      Console.WriteLine(e);
      return false;
    }catch{
      Console.WriteLine(Localize("INTERNAL COMPILER ERROR"));
      return false;
    }
    return isCompiled;
  }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:89,代码来源:jsc.cs


注:本文中的Microsoft.JScript.Vsa.VsaEngine.SetOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。