示例#1
0
        public void IntPropTest()
        {
            const int hvo  = 1;
            var       clid = SilDataAccess.MetaDataCache.GetClassId("ClassB");
            const int tag  = (int)CmObjectFields.kflidCmObject_Class;

            SilDataAccess.SetInt(hvo, tag, clid);
            var clid1 = SilDataAccess.get_IntProp(hvo, tag);

            Assert.AreEqual(clid, clid1, "Wrong clid in cache.");

            // See if the int is there via another method.
            // It should be there.
            bool isInCache;
            var  clid2 = VwCacheDa.get_CachedIntProp(hvo, tag, out isInCache);

            Assert.IsTrue(isInCache, "Int not in cache.");
            Assert.AreEqual(clid1, clid2, "Clids are not the same.");

            // See if the int is there via another method.
            // It should not be there.
            var ownerHvo = VwCacheDa.get_CachedIntProp(hvo, (int)CmObjectFields.kflidCmObject_Owner, out isInCache);

            Assert.IsFalse(isInCache, "Int is in cache.");
            Assert.AreEqual(0, ownerHvo, "Wrong owner.");
        }
示例#2
0
        public void StringPropWrongLengthFmtTest()
        {
            CheckDisposed();

            // Set class first, or it will throw an exception.
            int  hvo  = 1;
            uint clid = SilDataAccess.MetaDataCache.GetClassId("PhEnvironment");

            SilDataAccess.SetInt(hvo, (int)CmObjectFields.kflidCmObject_Class, (int)clid);
            int tag = (int)SilDataAccess.MetaDataCache.GetFieldId("PhEnvironment", "StringRepresentation", false);

            ITsPropsBldr propsBldr = TsPropsBldrClass.Create();

            propsBldr.SetStrPropValue((int)FwTextPropType.ktptNamedStyle, "Verse");
            ITsStrBldr strBldr = TsStrBldrClass.Create();

            // Test StringFields (which are basically the same, except that the
            // format of the parameters is different)
            strBldr.Replace(0, 0, "Third", propsBldr.GetTextProps());
            ITsString tsString = strBldr.GetString();
            int       cbFmt;

            byte[] rgbFmt;
            using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(1000, typeof(byte)))
            {
                cbFmt  = tsString.SerializeFmtRgb(arrayPtr, 1000);
                rgbFmt = (byte[])MarshalEx.NativeToArray(arrayPtr, cbFmt, typeof(byte));
            }
            VwCacheDa.CacheStringFields(hvo, tag, tsString.Text,
                                        tsString.Length, rgbFmt, cbFmt - 1);
        }
示例#3
0
        public void IntPropTest()
        {
            CheckDisposed();

            int  hvo  = 1;
            uint clid = SilDataAccess.MetaDataCache.GetClassId("PartOfSpeech");
            int  tag  = (int)CmObjectFields.kflidCmObject_Class;

            SilDataAccess.SetInt(hvo, tag, (int)clid);
            int clid1 = SilDataAccess.get_IntProp(hvo, tag);

            Assert.AreEqual((int)clid, clid1, "Wrong clid in cache.");

            // See if the int is there via another method.
            // It should be there.
            bool isInCache = false;
            int  clid2     = VwCacheDa.get_CachedIntProp(hvo, tag, out isInCache);

            Assert.IsTrue(isInCache, "Int not in cache.");
            Assert.AreEqual(clid1, clid2, "Clids are not the same.");

            // See if the int is there via another method.
            // It should not be there.
            isInCache = true;
            int ownerHvo = VwCacheDa.get_CachedIntProp(hvo, (int)CmObjectFields.kflidCmObject_Owner, out isInCache);

            Assert.IsFalse(isInCache, "Int is in cache.");
            Assert.AreEqual(0, ownerHvo, "Wrong owner.");
        }
示例#4
0
        /// <summary/>
        protected virtual void Dispose(bool fDisposing)
        {
            System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
            if (fDisposing && !IsDisposed)
            {
                // dispose managed and unmanaged objects
                if (m_cacheDa != null)
                {
                    m_cacheDa.ClearAllData();
                    if (Marshal.IsComObject(m_cacheDa))
                    {
                        Marshal.ReleaseComObject(m_cacheDa);
                    }
                }
            }
            m_cacheDa = null;

            IsDisposed = true;
        }
示例#5
0
		/// <summary/>
		protected virtual void Dispose(bool fDisposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			if (fDisposing && !IsDisposed)
			{
				// dispose managed and unmanaged objects
				if (m_cacheDa != null)
				{
					m_cacheDa.ClearAllData();
					if (Marshal.IsComObject(m_cacheDa))
						Marshal.ReleaseComObject(m_cacheDa);
				}
			}
			m_cacheDa = null;

			IsDisposed = true;
		}
示例#6
0
        public virtual void Exit()
        {
            CheckDisposed();

            VwCacheDa.ClearAllData();
        }