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


C# ScriptEngine.GetSearchPaths方法代码示例

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


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

示例1: GetEngine

        public ScriptEngine GetEngine()
        {
            if (_engine != null)
                return _engine;
            _engine = Python.CreateEngine();

            ScriptRuntimeSetup setup = new ScriptRuntimeSetup();
            setup.DebugMode = true;
            setup.LanguageSetups.Add(Python.CreateLanguageSetup(null));
            ScriptRuntime runtime = new ScriptRuntime(setup);
            _engine = runtime.GetEngineByTypeName(typeof(PythonContext).AssemblyQualifiedName);

            _engine.Runtime.IO.SetOutput(_stream, Encoding.UTF8);
            _engine.Runtime.IO.SetErrorOutput(_stream, Encoding.UTF8);
            string path = Environment.CurrentDirectory;
            string ironPythonLibPath = string.Format(@"{0}\IronPythonLib.zip", path);
            var paths = _engine.GetSearchPaths() as List<string> ?? new List<string>();
            paths.Add(path);
            paths.Add(ironPythonLibPath);
            path = Environment.GetEnvironmentVariable("IRONPYTHONPATH");
            if (!string.IsNullOrEmpty(path))
            {
                var pathStrings = path.Split(';');
                paths.AddRange(pathStrings.Where(p => p.Length > 0));
            }
            _engine.SetSearchPaths(paths.ToArray());
            return _engine;
        }
开发者ID:heyxEvget,项目名称:IronPython-Debugger,代码行数:28,代码来源:MainWindow.xaml.cs

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

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

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

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

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

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

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

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

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

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

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

示例13: Init

        private static void Init()
        {
            engine = IronPython.Hosting.Python.CreateEngine();
            scope = engine.CreateScope();
            var paths = engine.GetSearchPaths();
            paths.Add("C:\\Program Files (x86)\\Excel-REPL\\Excel-REPL\\Lib");
            paths.Add("C:\\Anaconda\\Lib");
            paths.Add("C:\\Program Files (x86)\\Excel-REPL\\Excel-REPL\\python");
            paths.Add("C:\\Users\\xuehuit\\Documents\\Visual Studio 2012\\Projects\\Excel-REPL\\Excel-REPL\\python");
            engine.SetSearchPaths(paths);

            String initCode = @"
            from pygments import highlight
            from pygments.lexers import ClojureLexer
            from pygments.formatters import HtmlFormatter

            clojureLexer = ClojureLexer()
            htmlFormatter = HtmlFormatter()

            def raw(code):
              return highlight(code, clojureLexer, htmlFormatter)";

            engine.Execute(initCode, scope);
        }
开发者ID:telefunkenvf14,项目名称:Excel-REPL,代码行数:24,代码来源:Python.cs

示例14: IPConsole

        public IPConsole()
        {
            script = "";
            old_code = "";
            old_entries = new List<string>();
            old_entry_num = 0;
            line = 1;
            cmd_prefix = ">>> ";
            new_cmd_line_prefix = "....";
            identation_indicator = "....";

            engine = Python.CreateEngine ();
            scope = engine.CreateScope ();

            var coll = engine.GetSearchPaths ();

            coll.Add (".");
            coll.Add("./ipython-lib");
            coll.Add("./ipython-dlls");

            engine.SetSearchPaths(coll);

            this.autocompleter = new PythonAutoComplete (this.engine, this.scope);
        }
开发者ID:tcpie,项目名称:simple-ironpython-console,代码行数:24,代码来源:Program.cs

示例15: RubyInstaller

        public RubyInstaller(string fileName)
        {
            this.fileName = fileName;
            var binFiles =  Directory.GetFiles(Environment.CurrentDirectory).ToList();

            var assemblies = new List<Assembly>();
            var appDomain = new List<Assembly>();
            appDomain.AddRange(AppDomain.CurrentDomain.GetAssemblies());

            foreach(var file in binFiles)
            {
                foreach (var assembly in appDomain)
                {
                    try
                    {
                        if (assembly.Location == file || (!file.EndsWith(".dll") && !file.EndsWith(".exe"))) continue;

                        assemblies.Add(Assembly.LoadFile(file));
                    }
                    catch (Exception)
                    {
                        //don't load the assembly
                    }
                }
            }

            assemblies.AddRange(appDomain);

            if(engine == null)
            {
               lock(@lock)
               {
                   if(engine == null)
                   {
                       engine = IronRuby.Ruby.CreateEngine();

                       var paths = engine.GetSearchPaths().ToList();
                       paths.Add(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
                       engine.SetSearchPaths(paths);

                       scope = engine.CreateScope();

                       assemblies.ForEach(a => engine.Runtime.LoadAssembly(a));
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.Installer.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.SiegeDSL.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RubyRegistration.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.RegistrationHandlerFactory.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.DefaultRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.DefaultInstanceRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.ConditionalRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.ConditionalInstanceRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.NamedRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.NamedInstanceRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.ConventionRegistrationHandler.rb");
                       LoadResource("Siege.ServiceLocator.Dynamic.Scripts.RegistrationHandlers.ConventionInstanceRegistrationHandler.rb");
                   }
               }
            }

            this.source = engine.CreateScriptSourceFromFile(this.fileName);
        }
开发者ID:rexwhitten,项目名称:Siege,代码行数:61,代码来源:RubyInstaller.cs


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