本文整理汇总了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;
}
示例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);
}
示例3: BasicScriptHost
public BasicScriptHost()
{
_engine = Python.CreateEngine();
var searchPaths = _engine.GetSearchPaths();
searchPaths.Add(IOHelper.ConvertToFullPath("./scripts/"));
_engine.SetSearchPaths(searchPaths);
}
示例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);
}
示例5: PyMarshaler
public PyMarshaler()
{
_engine = Python.CreateEngine();
_runtime = _engine.Runtime;
ICollection<string> searchPaths = _engine.GetSearchPaths();
searchPaths.Add("PyScripts");
_engine.SetSearchPaths(searchPaths);
}
示例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;
}
示例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);
}
示例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");
}
示例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>();
}
}
示例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);
}
示例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);
}
}
}
示例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.");
}
示例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);
}
示例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);
}
示例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);
}