PushSearchPath() public method

public PushSearchPath ( string path ) : void
path string
return void
コード例 #1
0
ファイル: Program.cs プロジェクト: qingfeng346/Scorpio-CSharp
        static void Main(string[] args) {
            script = new Script();
            Console.WriteLine("the current version : " + Script.Version);
            script.LoadLibrary();
            script.PushAssembly(typeof(Program).GetTypeInfo().Assembly);
#if !SCORPIO_NET_CORE
            string CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
#else
            string CurrentDirectory = "";
#endif
            LoadLibrary(Path.Combine(CurrentDirectory, "dll"));
            LoadFiles(Path.Combine(CurrentDirectory, "cs"));
            if (args.Length >= 1) {
                try {
                    string file = Path.GetFullPath(args[0]);
                    string path = Path.GetDirectoryName(file);
                    LoadLibrary(Path.Combine(path, "dll"));
                    LoadFiles(Path.Combine(path, "cs"));
                    Stopwatch watch = Stopwatch.StartNew();
                    script.PushSearchPath(CurrentDirectory);
                    script.PushSearchPath(path);
                    script.SetObject("__PATH__", path);
                    LibraryIO.Load(script);
                    Console.WriteLine("=============================");
                    ScriptObject value = script.LoadFile(file);
                    Console.WriteLine("=============================");
                    Console.WriteLine("return value : " + value);
                    Console.WriteLine("the execution time : " + watch.ElapsedMilliseconds + " ms");
                } catch (System.Exception ex) {
                    Console.WriteLine(script.GetStackInfo());
                    Console.WriteLine(ex.ToString());
                }
            } else {
                while (true) {
                    try {
                        string str = Console.ReadLine();
                        if (str == "exit")  { 
                            break;
                        } else if (str == "clear") {
                            Console.Clear();
                        } else if (str == "version") {
                            Console.WriteLine(Script.Version);
                        } else {
                            script.LoadString(str);
                        }
                    } catch (System.Exception ex) {
                        Console.WriteLine(script.GetStackInfo());
                        Console.WriteLine(ex.ToString());
                    }
                }
            }
        }