Exemple #1
0
        /// <summary>
        /// Destroys object
        /// </summary>
        public void Dispose()
        {
            if (_disposedFlag.Set())
            {
                _activeScriptGarbageCollector = null;
                if (_is64Bit)
                {
                    _activeScriptParse64 = null;
                }
                else
                {
                    _activeScriptParse32 = null;
                }

                ComHelpers.ReleaseAndEmpty(ref _pActiveScriptGarbageCollector);
                if (_is64Bit)
                {
                    ComHelpers.ReleaseAndEmpty(ref _pActiveScriptDebug64);
                    ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse64);
                }
                else
                {
                    ComHelpers.ReleaseAndEmpty(ref _pActiveScriptDebug32);
                    ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse32);
                }
                ComHelpers.ReleaseAndEmpty(ref _pActiveScript);

                if (_activeScript != null)
                {
                    _activeScript.Close();
                    Marshal.FinalReleaseComObject(_activeScript);
                    _activeScript = null;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Destroys object
 /// </summary>
 /// <param name="disposing">Flag, allowing destruction of
 /// managed objects contained in fields of class</param>
 private void Dispose(bool disposing)
 {
     if (_disposedFlag.Set())
     {
         if (_is64Bit)
         {
             _activeScriptParse64 = null;
             ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse64);
         }
         else
         {
             _activeScriptParse32 = null;
             ComHelpers.ReleaseAndEmpty(ref _pActiveScriptParse32);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Checks a support of the JavaScript engine on the machine
        /// </summary>
        /// <param name="clsid">CLSID of JavaScript engine</param>
        /// <param name="isSupported">Flag indicating whether this JavaScript engine is supported</param>
        /// <param name="supportSynchronizer">Support synchronizer</param>
        /// <returns>Result of check (true - supports; false - does not support)</returns>
        protected static bool IsSupported(string clsid, ref bool?isSupported, ref object supportSynchronizer)
        {
            if (isSupported.HasValue)
            {
                return(isSupported.Value);
            }

            lock (supportSynchronizer)
            {
                if (isSupported.HasValue)
                {
                    return(isSupported.Value);
                }

                IntPtr pActiveScript = IntPtr.Zero;

                try
                {
                    pActiveScript = ComHelpers.CreateInstanceByClsid <IActiveScript>(clsid);
                    isSupported   = true;
                }
                catch (COMException e)
                {
                    if (e.ErrorCode == ComErrorCode.ClassNotRegistered)
                    {
                        isSupported = false;
                    }
                    else
                    {
                        isSupported = null;
                    }
                }
                catch
                {
                    isSupported = null;
                }
                finally
                {
                    ComHelpers.ReleaseAndEmpty(ref pActiveScript);
                }

                return(isSupported.HasValue && isSupported.Value);
            }
        }
Exemple #4
0
        /// <summary>
        /// Destroys object
        /// </summary>
        /// <param name="disposing">Flag, allowing destruction of
        /// managed objects contained in fields of class</param>
        private void Dispose(bool disposing)
        {
            if (_disposedFlag.Set())
            {
                _dispatcher.Invoke(() =>
                {
                    if (_dispatch != null)
                    {
                        ComHelpers.ReleaseComObject(ref _dispatch, !disposing);
                        _dispatch = null;
                    }

                    _activeScriptGarbageCollector = null;
                    ComHelpers.ReleaseAndEmpty(ref _pActiveScriptGarbageCollector);

                    if (_activeScriptParse != null)
                    {
                        _activeScriptParse.Dispose();
                        _activeScriptParse = null;
                    }

                    if (_activeScript != null)
                    {
                        _activeScript.Close();
                        Marshal.FinalReleaseComObject(_activeScript);
                        _activeScript = null;
                    }

                    ComHelpers.ReleaseAndEmpty(ref _pActiveScript);
                });

                if (disposing)
                {
                    if (_hostItems != null)
                    {
                        _hostItems.Clear();
                    }

                    _lastException = null;
                }
            }
        }
        private void InnerDispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                if (_activeScriptSite != null)
                {
                    _activeScriptSite.Dispose();
                    _activeScriptSite = null;
                }

                if (_activeScript != null)
                {
                    _activeScript.Close();
                    _activeScript = null;
                }

                ComHelpers.ReleaseAndEmpty(ref _pActiveScript);
            }
        }
        /// <summary>
        /// Checks a support of the JavaScript engine on the machine
        /// </summary>
        /// <param name="clsid">CLSID of JavaScript engine</param>
        /// <returns>Result of check (true - supports; false - does not support)</returns>
        protected static bool IsSupported(string clsid)
        {
            bool   isSupported;
            IntPtr pActiveScript = IntPtr.Zero;

            try
            {
                pActiveScript = ComHelpers.CreateInstanceByClsid <IActiveScript>(clsid);
                isSupported   = true;
            }
            catch
            {
                isSupported = false;
            }
            finally
            {
                ComHelpers.ReleaseAndEmpty(ref pActiveScript);
            }

            return(isSupported);
        }