コード例 #1
0
        /// <summary>
        /// Initialises this script engine instance with the required internal components.
        /// </summary>
        /// <param name="activeScriptObject">The IActiveScript instance to initialise this script engine with.</param>
        private void Initialise(object activeScriptObject)
        {
            IActiveScript activeScriptInstance = activeScriptObject as IActiveScript;

            if (activeScriptInstance == null)
            {
                throw new InvalidActiveScriptClassException();
            }

            this.parser = ActiveScriptParse.MakeActiveScriptParse(activeScriptInstance);

            this.parser.InitNew();

            this.scriptSite = new ActiveScriptSite(this);
            activeScriptInstance.SetScriptSite(this.scriptSite);

            this.hostObjects = new Dictionary <string, object>();
            this.scripts     = new Dictionary <ulong, ScriptInfo>();

            this.activeScript = activeScriptInstance;
        }
コード例 #2
0
        /// <summary>
        /// Disposes the internal IActiveScript engine instance.
        /// </summary>
        /// <param name="managedDispose">Whether to dispose only managed resources.</param>
        protected virtual void Dispose(bool managedDispose)
        {
            if (activeScript != null)
            {
                try
                {
                    activeScript.Close();
                }
                finally
                {
                    activeScript = null;
                }
            }

            if (parser != null)
            {
                parser = null;
            }

            if (scriptSite != null)
            {
                scriptSite = null;
            }
        }