Changeset 339

Show
Ignore:
Timestamp:
10/20/07 19:20:19 (15 months ago)
Author:
tomoyo
Message:

リロード時にビルトインモジュールが削除されてしまうのでモジュールを自分で生成するようにした。

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Apple Wireless Keyboard Helper/trunk/Misuzilla.Applications.AppleWirelessKeyboardHelper/Program.cs

    r331 r339  
    99using System.IO; 
    1010using System.Text; 
     11using Microsoft.Scripting.Hosting; 
     12using System.Collections.Generic; 
    1113 
    1214namespace Misuzilla.Applications.AppleWirelessKeyboardHelper 
     
    1618        private static NotifyIcon _notifyIcon; 
    1719        private const String ApplicationName = "Apple Wireless Keyboard Helper"; 
     20        private static IScriptModule _module; 
    1821 
    1922        public static Int32 BalloonTipTimeout = 1500; 
     
    8891        private static void Call(String funcName, EventArgs e) 
    8992        { 
    90             if (!Script.VariableExists(funcName)) 
     93            Object funcObj; 
     94            if (!_module.TryLookupVariable(funcName, out funcObj)) 
    9195                return; 
    9296             
    93             FastCallable f = Script.GetVariable(funcName) as FastCallable; 
     97            FastCallable f = funcObj as FastCallable; 
    9498            if (f == null) 
    9599                return; 
     
    104108        } 
    105109 
     110 
     111         
    106112        /// <summary> 
    107113        ///  
     
    113119            Unload = null; 
    114120            Load = null; 
    115             Script.ClearVariables(); 
    116121 
    117122#pragma warning disable 0618 
     
    120125#pragma warning restore 0618 
    121126 
     127            IScriptEnvironment scriptEnv = ScriptEnvironment.GetEnvironment(); 
     128            List<ICompiledCode> compiledCodes = new List<ICompiledCode>(); 
     129            _module = scriptEnv.CreateModule("ScriptModule"); 
     130 
    122131            Boolean hasScripts = false; 
    123132            if (Directory.Exists("Scripts")) 
     
    128137                    try 
    129138                    { 
     139                        IScriptEngine engine = scriptEnv.GetLanguageProviderByFileExtension(Path.GetExtension(path)).GetEngine(); 
     140                        engine.ExecuteFileContent(path, _module); 
    130141                        hasScripts = true; 
    131                         Script.ExecuteFileContent(path); 
    132142                    } 
    133143                    catch (SyntaxErrorException se) 
     
    145155            if (!hasScripts) 
    146156            { 
    147                 Script.Execute("py", Resources.Strings.DefaultPythonScript); 
    148             } 
    149  
     157                Script.GetEngine("py").Execute(Resources.Strings.DefaultPythonScript, _module); 
     158            } 
     159 
     160            // ��s 
     161            _module.Execute(); 
     162             
    150163            OnLoad(EventArgs.Empty); 
    151164