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


C# VsaEngine.GetGlobalScope方法代码示例

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


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

示例1: PartialTrustEvaluationStrategy

            public PartialTrustEvaluationStrategy(string expression, VsaEngine engine)
                : base(engine)
            {
                //
                // Following is equivalent to declaring a "var" in JScript
                // at the level of the Global object.
                //

                _scope = (GlobalScope)engine.GetGlobalScope().GetObject();
                _contextField = _scope.AddField("$context");
                _expression = expression;
            }
开发者ID:buddydvd,项目名称:elmah-mirror,代码行数:12,代码来源:JScriptAssertion.cs

示例2: CreateEngineForDebugger

 internal static VsaEngine CreateEngineForDebugger(){
   VsaEngine engine = new VsaEngine(true);
   engine.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());
   GlobalScope scope = (GlobalScope)engine.GetGlobalScope().GetObject();
   scope.globalObject = engine.Globals.globalObject;
   return engine;
 }
开发者ID:ArildF,项目名称:masters,代码行数:7,代码来源:vsaengine.cs

示例3: CreateEngineWithType

      // This factory method is called by DLL code only
      public static VsaEngine CreateEngineWithType(RuntimeTypeHandle callingTypeHandle){
        Type callingType = Type.GetTypeFromHandle(callingTypeHandle);
        Assembly callingAssembly = callingType.Assembly;
        Object o = System.Runtime.Remoting.Messaging.CallContext.GetData("JScript:" + callingAssembly.FullName);
        if (o != null){
          VsaEngine e = o as VsaEngine;
          if (e != null)
            return e;
        }

        VsaEngine engine = new VsaEngine(callingAssembly);
        engine.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());

        GlobalScope scope = (GlobalScope)engine.GetGlobalScope().GetObject();
        scope.globalObject = engine.Globals.globalObject;

        // for every global class generated in this assembly make an instance and call the global code method
        int i = 0;
        Type globalClassType = null;
        do{
          String globalClassName = "JScript " + i.ToString();
          globalClassType = callingAssembly.GetType(globalClassName, false);
          if (globalClassType != null){
            engine.SetEnclosingContext(new WrappedNamespace("", engine));
            ConstructorInfo globalScopeConstructor = globalClassType.GetConstructor(new Type[]{typeof(GlobalScope)});
            MethodInfo globalCode = globalClassType.GetMethod("Global Code");
            Object globalClassInstance = globalScopeConstructor.Invoke(new Object[]{scope});
            globalCode.Invoke(globalClassInstance, new Object[0]);
          }
          i++;
        }while (globalClassType != null);

        if (o == null)
          System.Runtime.Remoting.Messaging.CallContext.SetData("JScript:" + callingAssembly.FullName, engine);
        return engine;
      }
开发者ID:ArildF,项目名称:masters,代码行数:37,代码来源:vsaengine.cs

示例4: CreateEngineAndGetGlobalScope

 public static GlobalScope CreateEngineAndGetGlobalScope(bool fast, String[] assemblyNames){
   VsaEngine engine = new VsaEngine(fast);
   engine.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());
   engine.doPrint = true;
   engine.SetEnclosingContext(new WrappedNamespace("", engine));
   foreach (String assemblyName in assemblyNames){
     VsaReference r = (VsaReference)engine.vsaItems.CreateItem(assemblyName, VsaItemType.Reference, VsaItemFlag.None);
     r.AssemblyName = assemblyName;
   }
   VsaEngine.exeEngine = engine;
   GlobalScope scope = (GlobalScope)engine.GetGlobalScope().GetObject();
   scope.globalObject = engine.Globals.globalObject;
   return scope;
 }
开发者ID:ArildF,项目名称:masters,代码行数:14,代码来源:vsaengine.cs

示例5: CreateEngineAndGetGlobalScopeWithType

 public static GlobalScope CreateEngineAndGetGlobalScopeWithType(bool fast, String[] assemblyNames, RuntimeTypeHandle callingTypeHandle){
   VsaEngine engine = new VsaEngine(fast);
   engine.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());
   engine.doPrint = true;
   engine.SetEnclosingContext(new WrappedNamespace("", engine));
   foreach (String assemblyName in assemblyNames){
     VsaReference r = (VsaReference)engine.vsaItems.CreateItem(assemblyName, VsaItemType.Reference, VsaItemFlag.None);
     r.AssemblyName = assemblyName;
   }
   // Put the engine in the CallContext so that calls to CreateEngineWithType will return this engine
   Type callingType = Type.GetTypeFromHandle(callingTypeHandle);
   Assembly callingAssembly = callingType.Assembly;
   System.Runtime.Remoting.Messaging.CallContext.SetData("JScript:" + callingAssembly.FullName, engine);
   // Get and return the global scope
   GlobalScope scope = (GlobalScope)engine.GetGlobalScope().GetObject();
   scope.globalObject = engine.Globals.globalObject;
   return scope;
 }
开发者ID:ArildF,项目名称:masters,代码行数:18,代码来源:vsaengine.cs

示例6: CreateEngineWithType

      // This factory method is called by DLL code only
      public static VsaEngine CreateEngineWithType(RuntimeTypeHandle callingTypeHandle){
        Type callingType = Type.GetTypeFromHandle(callingTypeHandle);
        Assembly callingAssembly = callingType.Assembly;
        Object o = System.Runtime.Remoting.Messaging.CallContext.GetData("JScript:" + callingAssembly.FullName);
        if (o != null){
          VsaEngine e = o as VsaEngine;
          if (e != null)
            return e;
        }

        VsaEngine engine = new VsaEngine(callingAssembly);
        engine.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());

        GlobalScope scope = (GlobalScope)engine.GetGlobalScope().GetObject();
        scope.globalObject = engine.Globals.globalObject;

        // for every global class generated in this assembly make an instance and call the global code method
        int i = 0;
        Type globalClassType = null;
        do{
          String globalClassName = "JScript " + i.ToString(CultureInfo.InvariantCulture);
          globalClassType = callingAssembly.GetType(globalClassName, false);
          if (globalClassType != null){
            engine.SetEnclosingContext(new WrappedNamespace("", engine));
            ConstructorInfo globalScopeConstructor = globalClassType.GetConstructor(new Type[]{typeof(GlobalScope)});
            MethodInfo globalCode = globalClassType.GetMethod("Global Code");
            try{
              Object globalClassInstance = globalScopeConstructor.Invoke(new Object[]{scope});
              globalCode.Invoke(globalClassInstance, new Object[0]);
            }catch(SecurityException){
              // [stesty] Due to bug 337909, if a JScript assembly is strongly-named but partially-trusted, it will
              //          not succeed here unless it also has the AllowPartiallyTrustedCallersAttribute.  We do not
              //          want to run this constructor with elevated permissions, so we work around by abandoning
              //          the attempt, thus disabling eval in this scenario.
              break;
            }
          }
          i++;
        }while (globalClassType != null);

        if (o == null)
          System.Runtime.Remoting.Messaging.CallContext.SetData("JScript:" + callingAssembly.FullName, engine);
        return engine;
      }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:45,代码来源:vsaengine.cs

示例7: CreateEngineAndGetGlobalScope

		public static GlobalScope CreateEngineAndGetGlobalScope (bool fast, string [] assembly_names)
		{
			int i, n;
			GlobalScope scope;

			VsaEngine engine = new VsaEngine (fast);			
			engine.InitVsaEngine ("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa",
					      new DefaultVsaSite ());
			n = assembly_names.Length;

			for (i = 0; i < n; i++) {
				string assembly_name = assembly_names [i];
				VsaReferenceItem r = (VsaReferenceItem) engine.Items.CreateItem (assembly_name,
												 VsaItemType.Reference,
												 VsaItemFlag.None);
				r.AssemblyName = assembly_name;
			}
			scope = (GlobalScope) engine.GetGlobalScope ().GetObject ();
			return scope;
		}
开发者ID:nickchal,项目名称:pash,代码行数:20,代码来源:VsaEngine.cs

示例8: CreateEngineWithType

 public static VsaEngine CreateEngineWithType(RuntimeTypeHandle callingTypeHandle)
 {
     Assembly runtimeAssembly = Type.GetTypeFromHandle(callingTypeHandle).Assembly;
     object data = System.Runtime.Remoting.Messaging.CallContext.GetData("JScript:" + runtimeAssembly.FullName);
     if (data != null)
     {
         VsaEngine engine = data as VsaEngine;
         if (engine != null)
         {
             return engine;
         }
     }
     VsaEngine engine2 = new VsaEngine(runtimeAssembly);
     engine2.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());
     GlobalScope scope = (GlobalScope) engine2.GetGlobalScope().GetObject();
     scope.globalObject = engine2.Globals.globalObject;
     int num = 0;
     Type type = null;
     do
     {
         string name = "JScript " + num.ToString(CultureInfo.InvariantCulture);
         type = runtimeAssembly.GetType(name, false);
         if (type != null)
         {
             engine2.SetEnclosingContext(new WrappedNamespace("", engine2));
             ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(GlobalScope) });
             MethodInfo method = type.GetMethod("Global Code");
             try
             {
                 object obj3 = constructor.Invoke(new object[] { scope });
                 method.Invoke(obj3, new object[0]);
             }
             catch (SecurityException)
             {
                 break;
             }
         }
         num++;
     }
     while (type != null);
     if (data == null)
     {
         System.Runtime.Remoting.Messaging.CallContext.SetData("JScript:" + runtimeAssembly.FullName, engine2);
     }
     return engine2;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:46,代码来源:VsaEngine.cs

示例9: CreateEngineAndGetGlobalScopeWithTypeAndRootNamespace

 public static GlobalScope CreateEngineAndGetGlobalScopeWithTypeAndRootNamespace(bool fast, string[] assemblyNames, RuntimeTypeHandle callingTypeHandle, string rootNamespace)
 {
     VsaEngine engine = new VsaEngine(fast);
     engine.InitVsaEngine("JScript.Vsa.VsaEngine://Microsoft.JScript.VsaEngine.Vsa", new DefaultVsaSite());
     engine.doPrint = true;
     engine.SetEnclosingContext(new WrappedNamespace("", engine));
     if (rootNamespace != null)
     {
         engine.SetEnclosingContext(new WrappedNamespace(rootNamespace, engine));
     }
     foreach (string str in assemblyNames)
     {
         VsaReference reference = (VsaReference) engine.vsaItems.CreateItem(str, JSVsaItemType.Reference, JSVsaItemFlag.None);
         reference.AssemblyName = str;
     }
     Assembly assembly = Type.GetTypeFromHandle(callingTypeHandle).Assembly;
     System.Runtime.Remoting.Messaging.CallContext.SetData("JScript:" + assembly.FullName, engine);
     GlobalScope scope = (GlobalScope) engine.GetGlobalScope().GetObject();
     scope.globalObject = engine.Globals.globalObject;
     return scope;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:VsaEngine.cs

示例10: Evaluator

        public Evaluator(Evaluator theEvaluator)
        {
            ICodeCompiler compiler;
            compiler = new JScriptCodeProvider().CreateCompiler();

            CompilerParameters parameters;
            parameters = new CompilerParameters();
            parameters.GenerateInMemory = true;

            CompilerResults results;
            results = compiler.CompileAssemblyFromSource(parameters, _jscriptSource);

            Assembly assembly = results.CompiledAssembly;
            _evaluatorType = assembly.GetType("EvaluatorNS.Evaluator");
            //_evaluatorCtxType = assembly.GetType("Evaluator.Context");
            _evaluator = Activator.CreateInstance(_evaluatorType);

            // create a new form instance
            // _scriptableForm = new ScriptableForm();

            // create a new set of hosts
            lock (hosts)
            {
                string rootMoniker = string.Format("{0}://{1}", rootHostName, Guid.NewGuid().ToString());
                _host = new VsaScriptingHost(VsaScriptingLanguages.JScript, "Evaluator", rootMoniker,
                                             _evaluatorType.Namespace, true);
                Engine = (VsaEngine)(object)_host.Engine;
                globalScope = Engine.GetGlobalScope();
                thisGlobalObj = Microsoft.JScript.Eval.JScriptEvaluate("this;", Engine) as GlobalScope;
                hosts.Add(_host);
                _host.AddType(typeof(System.Object));
                _host.AddType(typeof(System.String));
                AddGlobalItem("$engine", Engine);
                AddGlobalItem("$superE", theEvaluator);
                // hosts.AddRange(HostFactory.Create(@"MyScriptingHost", @"Scripting", true, Environment.CurrentDirectory));                
            }

            // wire up to the events of each host
            foreach (VsaScriptingHost host in hosts)
            {
                host.AssemblyReferencesNeeded += new ScriptingHostEventHandler(OnAssemblyReferencesNeeded);
                host.CompilerException += new ScriptingHostCompilerExceptionEventHandler(OnCompilerException);
                host.GlobalItemsNeeded += new ScriptingHostEventHandler(OnGlobalItemsNeeded);
            }

            // execute the hosts
            foreach (VsaScriptingHost host in hosts)
                host.Execute();


            // show the form
            //_scriptableForm.ShowDialog();

        }
开发者ID:drzo,项目名称:opensim4opencog,代码行数:54,代码来源:JavaScriptInterpreter.cs


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