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


C# ScriptEngine.SetSearchPaths方法代码示例

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


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

示例1: initRuby

        private void initRuby()
        {
            ScriptRuntimeSetup runtimeSetup = ScriptRuntimeSetup.ReadConfiguration();
            var languageSetup = IronRuby.RubyHostingExtensions.AddRubySetup(runtimeSetup);

            runtimeSetup.DebugMode = false;
            runtimeSetup.PrivateBinding = false;
            runtimeSetup.HostType = typeof(RhoHost);

            languageSetup.Options["NoAdaptiveCompilation"] = false;
            languageSetup.Options["CompilationThreshold"] = 0;
            languageSetup.Options["Verbosity"] = 2;

            m_runtime = IronRuby.Ruby.CreateRuntime(runtimeSetup);
            m_engine = IronRuby.Ruby.GetEngine(m_runtime);
            m_context = (RubyContext)Microsoft.Scripting.Hosting.Providers.HostingHelpers.GetLanguageContext(m_engine);

            m_context.ObjectClass.SetConstant("RHO_WP7", 1);
            m_context.ObjectClass.AddMethod(m_context, "__rhoGetCallbackObject", new RubyLibraryMethodInfo(
                new[] { LibraryOverload.Create(new Func<System.Object, System.Int32, System.Object>(RhoKernelOps.__rhoGetCallbackObject), false, 0, 0) },
                RubyMethodVisibility.Public,
                m_context.ObjectClass
            ));
            m_context.Loader.LoadAssembly("RhoRubyLib", "rho.rubyext.rubyextLibraryInitializer", true, true);

            System.Collections.ObjectModel.Collection<string> paths = new System.Collections.ObjectModel.Collection<string>();
            paths.Add("lib");
            paths.Add("apps/app");
            m_engine.SetSearchPaths(paths);
        }
开发者ID:douglaslise,项目名称:rhodes,代码行数:30,代码来源:RhoRuby.cs

示例2: Load

        public override IEnumerable<Kbtter4Plugin> Load(Kbtter instance, IList<string> filenames)
        {
            var files = filenames.Where(p => p.EndsWith(".py"));
            var ret = new List<Kbtter4IronPythonPlugin>();

            engine = Python.CreateEngine();

            var context = HostingHelpers.GetLanguageContext(engine) as PythonContext;
            var path = context.GetSearchPaths();
            path.Add(Environment.CurrentDirectory + "\\");
            engine.SetSearchPaths(path);

            engine.Runtime.LoadAssembly(typeof(Status).Assembly);

            foreach (var i in files)
            {
                try
                {
                    var scope = engine.CreateScope();
                    scope.SetVariable("Kbtter4", new Kbtter4PluginProvider(instance));
                    var src = engine.CreateScriptSourceFromFile(i);
                    var code = src.Compile();
                    code.Execute(scope);
                    var p = new Kbtter4IronPythonPlugin(scope,instance);
                    ret.Add(p);
                }
                catch (Exception e)
                {
                    instance.LogError(String.Format("プラグイン読み込み中にエラーが発生しました : {0}\n{1}", i, e.Message));

                }
            }

            return ret;
        }
开发者ID:kb10uy,项目名称:Kbtter4,代码行数:35,代码来源:Kbtter4IronPythonPlugin.cs

示例3: initRuby

        private void initRuby()
        {
            ScriptRuntimeSetup runtimeSetup = ScriptRuntimeSetup.ReadConfiguration();
            var languageSetup = IronRuby.RubyHostingExtensions.AddRubySetup(runtimeSetup);

            runtimeSetup.DebugMode = false;
            runtimeSetup.PrivateBinding = false;
            runtimeSetup.HostType = typeof(RhoHost);

            languageSetup.Options["NoAdaptiveCompilation"] = false;
            languageSetup.Options["CompilationThreshold"] = 0;
            languageSetup.Options["Verbosity"] = 2;

            m_runtime = IronRuby.Ruby.CreateRuntime(runtimeSetup);
            m_engine = IronRuby.Ruby.GetEngine(m_runtime);
            m_context = (RubyContext)Microsoft.Scripting.Hosting.Providers.HostingHelpers.GetLanguageContext(m_engine);

            m_context.ObjectClass.SetConstant("RHO_WP7", 1);
            m_context.Loader.LoadAssembly("RhoRubyLib", "rho.rubyext.rubyextLibraryInitializer", true, true);

            System.Collections.ObjectModel.Collection<string> paths = new System.Collections.ObjectModel.Collection<string>();
            paths.Add("lib");
            paths.Add("apps/app");
            m_engine.SetSearchPaths(paths);
        }
开发者ID:artemk,项目名称:rhodes,代码行数:25,代码来源:RhoRuby.cs

示例4: PythonEngine

        public PythonEngine(string scriptsPath)
        {
            Log.Notice("PythonEngine", sLConsole.GetString("Initializing Python engine."));
            _scriptPath = scriptsPath;
            _engine = Python.CreateEngine();

            string dir = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
            var list = new List<string>();
            list.Add(Path.Combine(dir, "Schumix.Irc.dll"));
            list.Add(Path.Combine(dir, "Schumix.Framework.dll"));

            foreach(var l in list)
                _engine.Runtime.LoadAssembly(Assembly.LoadFile(l));

            list.Clear();

            var paths = _engine.GetSearchPaths();
            paths.Add(_scriptPath);
            paths.Add(Path.Combine(_scriptPath, "Libs"));
            _engine.SetSearchPaths(paths);

            LoadScripts();

            _watcher = new FileSystemWatcher(_scriptPath)
            {
                NotifyFilter = NotifyFilters.FileName | NotifyFilters.Attributes | NotifyFilters.LastAccess |
                NotifyFilters.LastWrite | NotifyFilters.Security | NotifyFilters.Size,
                EnableRaisingEvents = true
            };

            _watcher.Created += (s, e) => LoadScripts(true);
            _watcher.Changed += (s, e) => LoadScripts(true);
            _watcher.Deleted += (s, e) => LoadScripts(true);
            _watcher.Renamed += (s, e) => LoadScripts(true);
        }
开发者ID:Schumix,项目名称:Schumix2,代码行数:35,代码来源:PythonEngine.cs

示例5: BasicScriptHost

        public BasicScriptHost()
        {
            _engine = Python.CreateEngine();

            var searchPaths = _engine.GetSearchPaths();
            searchPaths.Add(IOHelper.ConvertToFullPath("./scripts/"));
            _engine.SetSearchPaths(searchPaths);
        }
开发者ID:virtualdreams,项目名称:csharp-python-sample,代码行数:8,代码来源:Program.cs

示例6: Interpreter

		public Interpreter()
		{
			pyEngine = Python.CreateEngine();
			pyRuntime = pyEngine.Runtime;
			pyScope = pyEngine.CreateScope();
			var paths = pyEngine.GetSearchPaths();
			paths.Add(Path.Combine(Logic.Client.ExecutingDirectory, "Client", "LIB"));
			pyEngine.SetSearchPaths(paths);
		}
开发者ID:osiato,项目名称:LegendaryClient,代码行数:9,代码来源:Interpreter.cs

示例7: PyMarshaler

        public PyMarshaler()
        {
            _engine = Python.CreateEngine();
            _runtime = _engine.Runtime;

            ICollection<string> searchPaths = _engine.GetSearchPaths();
            searchPaths.Add("PyScripts");
            _engine.SetSearchPaths(searchPaths);
        }
开发者ID:Civa,项目名称:pyinterop,代码行数:9,代码来源:PyMarshaler.cs

示例8: PythonEngine

 public PythonEngine(Game game)
 {
     _engine = Python.CreateEngine();
     var searchPaths = _engine.GetSearchPaths().ToList();
     var pythonPath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Scripting", "PythonIncludes");
     searchPaths.Add(pythonPath);
     _engine.SetSearchPaths(searchPaths);
     _engine.Runtime.Globals.SetVariable("WumpusGame", game);
     _game = game;
 }
开发者ID:ThreeToes,项目名称:ExtensiWumpus,代码行数:10,代码来源:PythonEngine.cs

示例9: ScriptingManager

 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="manager">The callback manager</param>
 /// <param name="contacts">The contact manager</param>
 public ScriptingManager(CallbackManager manager, ContactManager contacts)
 {
     _contactManager = contacts;
     _callbackManager = manager;
     _engine = Python.CreateEngine();
     var searchPaths = new List<string>(_engine.GetSearchPaths());
     searchPaths.Add(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "PythonLib"));
     _engine.SetSearchPaths(searchPaths);
     _engine.Runtime.Globals.SetVariable("callbackManager", _callbackManager);
     _engine.Runtime.Globals.SetVariable("contactManagerObject", _contactManager);
 }
开发者ID:ThreeToes,项目名称:IronPythonDemo,代码行数:16,代码来源:ScriptingManager.cs

示例10: Initialise

 public void Initialise(Scene scene, IConfigSource config)
 {
     m_log.Info("[PythonModuleLoader] Initializing...");
     m_scene = scene;
     m_config = config;
     m_pyengine = Python.CreateEngine();
     m_pyscope = m_pyengine.CreateScope();
     ICollection<string> paths = m_pyengine.GetSearchPaths();
     paths.Add(AppDomain.CurrentDomain.BaseDirectory);
     paths.Add(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ScriptEngines"));
     m_pyengine.SetSearchPaths(paths);
     m_log.Info("Added " + AppDomain.CurrentDomain.BaseDirectory + " to python module search path");
 }
开发者ID:AlphaStaxLLC,项目名称:OpensimPython,代码行数:13,代码来源:PythonModuleLoader.cs

示例11: InitScriptEngine

 public static void InitScriptEngine(bool debug)
 {
     if (engine == null || loadedModules == null || errors == null)
     {
         engine = Python.CreateEngine();
         engine.SetTrace(null);
         var paths = engine.GetSearchPaths();
         paths.Add(HostingEnvironment.MapPath(@"~/Python"));
         paths.Add(HostingEnvironment.MapPath(@"~/Protoplasm-Python"));
         engine.SetSearchPaths(paths);
         loadedModules = new Dictionary<string,int>();
         errors = new List<string>();
     }
 }
开发者ID:kevincos,项目名称:Protoplasm,代码行数:14,代码来源:PythonScriptEngine.cs

示例12: RubyEngine

        private RubyEngine()
        {
            string directory = Directory.GetCurrentDirectory();
            Console.WriteLine(directory);
            engine = IronRuby.Ruby.CreateEngine();
            engine.SetSearchPaths(new List<string>()
                                      {
                                          String.Format(@"{0}\IronRuby", physicalPath),
                                          String.Format(@"{0}\ruby\site_ruby\1.8", physicalPath),
                                          String.Format(@"{0}\ruby\1.8", physicalPath),
                                          //@".\lib\\IronRuby\gems\1.8\gems\less-1.1.13\lib\vendor\treetop\lib",
                                          String.Format(@"{0}\IronRuby\gems\1.8\gems\less-1.1.13\lib\", physicalPath)
                                      });

            scope = engine.CreateScope();
            engine.Execute(@"require 'less'", scope);
        }
开发者ID:Tigraine,项目名称:IronLess.Net,代码行数:17,代码来源:RubyEngine.cs

示例13: Main

        public static void Main(string[] args)
        {
            Assembly.LoadFile("IronRuby.dll");
            Assembly.LoadFile("IronRuby.Libraries.dll");

            engine = IronRuby.Ruby.CreateEngine();
            var paths = engine.GetSearchPaths().ToList();
            paths.Add(Path.Combine("ruby", "Lib", "ironruby"));
            paths.Add(Path.Combine("ruby", "Lib", "ruby", "1.9.1"));
            engine.SetSearchPaths(paths);

            engine.Runtime.LoadAssembly(Assembly.LoadFile(Assembly.GetExecutingAssembly().Location));
            engine.Runtime.LoadAssembly(Assembly.LoadFile("LibuvSharp.dll"));

            if (System.IO.Directory.Exists("ruby")) {
                foreach (string file in System.IO.Directory.GetFiles("ruby", "*.rb")) {
                    Load(file);
                }
            }
        }
开发者ID:oskarwkarlsson,项目名称:LibuvSharp,代码行数:20,代码来源:MainClass.cs

示例14: IRE

        private IRE()
        {
            LogsTailLength = 1000;

            _defaultEngine = Ruby.CreateEngine((setup) => {
                setup.ExceptionDetail = true;
            });

            var paths = (new[] { Environment.CurrentDirectory, Environment.CurrentDirectory + @"\scripts"});
            paths.ToList().AddRange(_defaultEngine.GetSearchPaths());
            _defaultEngine.SetSearchPaths(paths);
            _defaultEngine.Runtime.LoadAssembly(typeof(IRE).Assembly);

            _outStream = new MemoryStream();

            _errStream = new MemoryStream();

            _defaultEngine.Runtime.IO.SetOutput(_outStream, Encoding.UTF8);
            _defaultEngine.Runtime.IO.SetErrorOutput(_errStream, Encoding.UTF8);
        }
开发者ID:homoluden,项目名称:IREngine,代码行数:20,代码来源:IRE.cs

示例15: EngineRun

        private void EngineRun() {
            lock(_pyLock) {
                _pyEngine = Python.CreateEngine();
                _pyEngine.Runtime.IO.SetOutput(_engineOutput, new StreamWriter(_engineOutput, System.Text.Encoding.UTF8));
                ICollection<string> paths = _pyEngine.GetSearchPaths();
                string path = Path.GetDirectoryName(_filePath);
                _logger.Log(path);
                paths.Add(path);
                _pyEngine.SetSearchPaths(paths);

                _pyScope = _pyEngine.CreateScope();
            }

            _logger.Log("Engine started. Initializing TerminalOS.");
            try {
                _pyEngine.ExecuteFile(_filePath, _pyScope);
            }
            catch (Exception e) {
                _logger.Log(e.Message + e.StackTrace);
            }

            _logger.Log("TerminalOS has stopped.");
        }
开发者ID:BrianErikson,项目名称:ScriptingTheGame,代码行数:23,代码来源:TerminalOS.cs


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