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


C# VsaEngine.SetEnclosingContext方法代码示例

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


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

示例1: JScriptImport

 public static void JScriptImport(String name, VsaEngine engine){
   int dotPos = name.IndexOf('.');
   String rootName = dotPos > 0 ? name.Substring(0, dotPos) : name;
   GlobalScope scope = ((IActivationObject)engine.ScriptObjectStackTop()).GetGlobalScope();
   FieldInfo field = scope.GetLocalField(rootName);
   if (field == null)
     field = scope.AddNewField(rootName, Namespace.GetNamespace(rootName, engine), FieldAttributes.Public|FieldAttributes.Literal);
   engine.SetEnclosingContext(new WrappedNamespace(name, engine, false));
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:9,代码来源:import.cs

示例2: JScriptImport

 public static void JScriptImport(string name, VsaEngine engine)
 {
     int index = name.IndexOf('.');
     string str = (index > 0) ? name.Substring(0, index) : name;
     GlobalScope globalScope = ((IActivationObject) engine.ScriptObjectStackTop()).GetGlobalScope();
     if (globalScope.GetLocalField(str) == null)
     {
         FieldInfo info = globalScope.AddNewField(str, Namespace.GetNamespace(str, engine), FieldAttributes.Literal | FieldAttributes.Public);
     }
     engine.SetEnclosingContext(new WrappedNamespace(name, engine, false));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:Import.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: 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

示例5: 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

示例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: 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

示例8: 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


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