public void MultiStringVirtualHandler()
        {
            CheckDisposed();

            MultiStringVirtualHandler msvh = new MultiStringVirtualHandler("LexDb", "NewString");

            m_fdoCache.InstallVirtualProperty(msvh);
            Assert.IsTrue(msvh.Writeable);
            Assert.AreEqual((int)CellarModuleDefns.kcptMultiString, msvh.Type);
            Assert.IsFalse(msvh.ComputeEveryTime);

            int hvoLexDb = 0;

            if (m_fdoCache.LangProject != null &&
                m_fdoCache.LangProject.LexDbOA != null)
            {
                hvoLexDb = m_fdoCache.LangProject.LexDbOA.Hvo;
            }
            if (hvoLexDb == 0)
            {
                // Rather than try to create a real LexDb, simulate one.
                hvoLexDb = khvoTest;
            }
            ISilDataAccess sda    = m_fdoCache.MainCacheAccessor;
            IVwCacheDa     cda    = sda as IVwCacheDa;
            int            wsVern = m_fdoCache.LangProject.DefaultVernacularWritingSystem;

            msvh.Load(hvoLexDb, msvh.Tag, wsVern, cda);
            ITsStrFactory tsf  = TsStrFactoryClass.Create();
            ITsString     tss  = tsf.MakeString("", wsVern);
            ITsString     tss1 = sda.get_MultiStringAlt(hvoLexDb, msvh.Tag, wsVern);

            Assert.IsTrue(tss.Equals(tss1));
            Assert.IsTrue(msvh.Writeable);
            tss = tsf.MakeString("This is a test", wsVern);
            msvh.WriteObj(hvoLexDb, msvh.Tag, wsVern, tss, sda);
            cda.CacheStringAlt(hvoLexDb, msvh.Tag, wsVern, tss);
            tss1 = sda.get_MultiStringAlt(hvoLexDb, msvh.Tag, wsVern);
            Assert.IsTrue(tss.Equals(tss1));
        }
Beispiel #2
0
        /// <summary>
        /// This will install a virtual handler for getting and setting temporary strings in each column.
        /// </summary>
        private void InstallVirtualHandlersForColumns()
        {
            // handle editableRow attributes
            Debug.Assert(m_xbv != null);
            FdoCache cache = m_xbv.Cache;

            Debug.Assert(cache != null);
            IVwCacheDa cda = cache.MainCacheAccessor as IVwCacheDa;

            // install a handler for each column
            for (int i = 1; i <= m_columns.Count; ++i)
            {
                string            sField = ksEditColumnBaseName + i;
                IVwVirtualHandler vh     = cda.GetVirtualHandlerName(
                    EditRowModelClass, sField);
                if (vh == null)
                {
                    MultiStringVirtualHandler msvh =
                        new MultiStringVirtualHandler(EditRowModelClass, sField);
                    cda.InstallVirtual(msvh);
                }
            }
        }