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


C# ScriptEngine.GetBuiltinModule方法代码示例

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


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

示例1: Form1

        public Form1()
        {
            InitializeComponent();

            _options = new Dictionary<string, object>();

            Python.CreateRuntimeSetup(_options);

            _options.Add("Frames", true);

            _engine = Python.CreateRuntime(_options).GetEngine("python");//setup.Options["Frames"] = true;

            try
            {
                _builtin = _engine.GetBuiltinModule();
                SetWorkDir();
                _scope = _engine.CreateScope();
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Error initialization");
            }
        }
开发者ID:Buket,项目名称:embedNumpy_Scipy_in_sharp,代码行数:23,代码来源:Form1.cs

示例2: InitializePython

        /// <summary>
        /// Initializes the Python engine
        /// </summary>
        private void InitializePython()
        {
            // Create the Python engine
            PythonEngine = IronPython.Hosting.Python.CreateEngine();

            var paths = PythonEngine.GetSearchPaths();
            paths.Add(Path.Combine(Interface.GetMod().InstanceDirectory, "Lib"));
            PythonEngine.SetSearchPaths(paths);

            PythonEngine.GetBuiltinModule().SetVariable("__import__", new ImportDelegate(DoImport));
            PythonEngine.GetBuiltinModule().RemoveVariable("execfile");
            PythonEngine.GetBuiltinModule().RemoveVariable("exit");
            PythonEngine.GetBuiltinModule().RemoveVariable("file");
            PythonEngine.GetBuiltinModule().RemoveVariable("input");
            PythonEngine.GetBuiltinModule().RemoveVariable("open");
            PythonEngine.GetBuiltinModule().RemoveVariable("raw_input");
            PythonEngine.GetBuiltinModule().RemoveVariable("reload");

            PythonEngine.Execute(
            @"class Command:
            def __init__(self, *dec_args, **dec_kw):
            self.dec_args = dec_args
            self.dec_kw = dec_kw
            self.name = list(self.dec_args)
            self.permission = []
            name = self.dec_kw.get('name', [])
            if not isinstance(name, list):
            name = [name]
            self.name = self.name + name
            permission = self.dec_kw.get('permission', [])
            if not isinstance(permission, list):
            permission = [permission]
            self.permission = self.permission + permission
            permission = self.dec_kw.get('permissions', [])
            if not isinstance(permission, list):
            permission = [permission]
            self.permission = self.permission + permission
            def __call__(self, f):
            self.f = f
            self.f.isCommand = True
            self.f.name = self.name
            self.f.permission = self.permission
            return self.f", PythonEngine.GetBuiltinModule());
        }
开发者ID:romgerman,项目名称:Oxide,代码行数:47,代码来源:PythonExtension.cs

示例3: InitializeEngine

        /// <summary> スクリプティングAPIの設定にもとづいて初期化を行う </summary>
        /// <param name="api">APIとなるインスタンス</param>
        /// <param name="globals">グローバル変数</param>
        private void InitializeEngine(IScriptApi api, PythonDictionary globals)
        {
            _ironPythonEngine = Python.CreateEngine();
            //名前参照にexeのディレクトリとキャラのディレクトリを追加
            var paths = _ironPythonEngine.GetSearchPaths();
            paths.Add(Environment.CurrentDirectory);
            paths.Add(DirectoryNames.GetCharacterScriptDirectory(api.CharacterName));
            _ironPythonEngine.SetSearchPaths(paths);

            //可視領域を限界まで広く取るためビルトインスコープにぶち込んでおく
            ScriptScope builtin = _ironPythonEngine.GetBuiltinModule();
            builtin.SetVariable(IronPythonCommonVariableNames.ApiVariableName, api);
            builtin.SetVariable(IronPythonCommonVariableNames.ApiGlobalDictionaryName, globals);
        }
开发者ID:malaybaku,项目名称:harriet,代码行数:17,代码来源:IronPythonMainScriptReader.cs


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