Exemplo n.º 1
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected virtual void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (m_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_app != null)
                {
                    m_app.Dispose();                     // Ensure cache disposed and WSF shutdown.
                }
                if (m_inMemoryCache != null)
                {
                    m_inMemoryCache.Dispose();
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_app           = null;
            m_mainWnd       = null;
            m_inMemoryCache = null;

            m_isDisposed = true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the bug.
        ///
        /// If subclasses override this method, they should call the base implementation.
        /// </remarks>
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                // Dispose managed resources here.
                if (m_inMemoryCache != null)
                {
                    if (m_inMemoryCache != null)
                    {
                        m_inMemoryCache.Dispose();
                    }
                }
            }

            // Dispose unmanaged resources here, whether disposing is true or false.
            m_inMemoryCache = null;

            base.Dispose(disposing);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            CheckDisposed();
            if (m_mock != null)
            {
                m_mock.Dispose();
            }

            m_mock = InMemoryFdoCache.CreateInMemoryFdoCache();
            m_mock.InitializeWritingSystemEncodings();
            m_mock.InitializeLangProject();
            m_lp = m_mock.Cache.LangProject;
        }
        public void SetUp()
        {
            CheckDisposed();
            if (m_cache != null)
            {
                m_cache.Dispose();
            }

            m_cache = InMemoryFdoCache.CreateInMemoryFdoCache();
            m_cache.InitializeWritingSystemEncodings();
            ILgWritingSystemFactory lgwsf = m_cache.Cache.LanguageWritingSystemFactoryAccessor;

            m_ws = lgwsf.get_EngineOrNull(InMemoryFdoCache.s_wsHvos.En);
        }
Exemplo n.º 5
0
        public void MultiMessageSynchronize_DifferentCache()
        {
            CheckDisposed();

            m_mainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything());
            m_mainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
            m_app.MainWindows.Add((IFwMainWnd)m_mainWnd.MockInstance);

            InMemoryFdoCache differentCache = InMemoryFdoCache.CreateInMemoryFdoCache();

            try
            {
                DynamicMock otherMainWnd = new DynamicMock(typeof(IFwMainWnd));
                otherMainWnd.SetupResult("Cache", differentCache.Cache);
                otherMainWnd.ExpectAndReturn("PreSynchronize", true, new IsAnything());
                otherMainWnd.ExpectAndReturn("Synchronize", true, new IsAnything());
                m_app.MainWindows.Add((IFwMainWnd)otherMainWnd.MockInstance);

                m_app.SuppressSynchronize(Cache);
                m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), Cache);
                m_app.Synchronize(new SyncInfo(SyncMsg.ksyncUndoRedo, 0, 0), differentCache.Cache);

                // This should call (Pre)Synchronize once for each main window
                m_app.ResumeSynchronize(Cache);

                m_mainWnd.Verify();
                otherMainWnd.Verify();
            }
            finally
            {
                differentCache.Dispose();
            }
        }
Exemplo n.º 6
0
 public void Teardown()
 {
     if (m_dlgWsProps != null)
     {
         m_dlgWsProps.Dispose();
         m_dlgWsProps = null;
     }
     m_inMemoryCache.Dispose();
 }
Exemplo n.º 7
0
 public void Teardown()
 {
     m_inMemoryCache.Dispose();
 }