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


C# ScriptEngine.GetSysModule方法代码示例

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


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

示例1: InitializePythonEngine

        private void InitializePythonEngine()
        {
            _engine = Python.CreateEngine(new Dictionary<string, object> {{"PrivateBinding", true}});

            _output = new FileToLog(_logger);
            // redirecionar o output para a caixa de texto
            _engine.GetSysModule().SetVariable("stdout", _output);
            _engine.GetSysModule().SetVariable("stderr", _output);
            // outra hipotese seria interceptar IO em _engine.Runtime.IO

            _engine.Runtime.LoadAssembly(GetType().Assembly);
            foreach (var referencedAssembly in GetType().Assembly.GetReferencedAssemblies())
            {
                _engine.Runtime.LoadAssembly(Assembly.Load(referencedAssembly));
            }
        }
开发者ID:brunomlopes,项目名称:techdays2010pt-ironpython,代码行数:16,代码来源:MainWindow.xaml.cs

示例2: CreateEngine

        /// <summary>
        /// Create new scripting engine
        /// </summary>
        /// <param name="runtime">Instance of the current runtime enviroement</param>
        /// <returns>Instance of IP script engine</returns>
        public ScriptEngine CreateEngine(ScriptRuntime runtime)
        {
            scriptEngine = runtime.GetEngineByTypeName(typeof(PythonContext).AssemblyQualifiedName);

            // Override import functionality
            ScriptScope scope = IronPython.Hosting.Python.GetBuiltinModule(scriptEngine);
            scope.SetVariable("__import__", new ImportDelegate(ResolveImport));

            var sysScope = scriptEngine.GetSysModule();

            List path_hooks = sysScope.GetVariable("path_hooks");

            // Disable zipimporter if needed
            for (int i = 0; i < path_hooks.Count; i++)
            {
                if (path_hooks.ElementAt(i) != null)
                {
                    PythonType type = path_hooks.ElementAt(i) as PythonType;
                    string name = PythonType.Get__name__(type);

                    if (name == "zipimporter" && EnableZipImporter == false)
                    {
                        path_hooks.RemoveAt(i);
                    }
                }
            }

            PythonType genericimporter = DynamicHelpers.GetPythonType(new GenericImportModule.genericimporter());
            path_hooks.Add(genericimporter);

            sysScope.SetVariable("path_hooks", path_hooks);

            return scriptEngine;
        }
开发者ID:simplic-systems,项目名称:simplic-dlr,代码行数:39,代码来源:IronPythonLanguage.cs


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