Ejemplo n.º 1
0
        public void TestSetGuid_ForNonCmObjectGuid()
        {
            int  objFlid    = (int)CmObjectFields.kflidCmObject_Guid;
            int  nonObjFlid = 9005;            //CmFilterTags.kflidApp
            int  objHvo1    = 1124;
            int  objHvo2    = 1125;
            Guid guid       = Guid.NewGuid();

            // Save the guids. When this test failed, the saved guid for object objHvo2
            // clobbered the saved guid for object objHvo1 so there was no longer longer
            // a guid in the object cache for object objHvo1.
            m_ISilDataAccess.SetGuid(objHvo1, objFlid, guid);
            m_ISilDataAccess.SetGuid(objHvo2, nonObjFlid, guid);

            // Make sure the correct hvo is returned when
            // trying to create an object from the guid.
            Assert.AreEqual(objHvo1, m_ISilDataAccess.get_ObjFromGuid(guid));

            m_IVwCacheDa.ClearAllData();

            // Now save the guids in the reverse order from the order saved above.
            m_ISilDataAccess.SetGuid(objHvo2, nonObjFlid, guid);
            m_ISilDataAccess.SetGuid(objHvo1, objFlid, guid);

            // Make sure the same flid is returned when the saving is reversed.
            Assert.AreEqual(objHvo1, m_ISilDataAccess.get_ObjFromGuid(guid));
        }
Ejemplo n.º 2
0
        public void TestUpdatePropIfCached()
        {
            // Create two test objects and add them to the language project.
            // It doesn't really matter what type of object they are as long
            // as the object contains at least one guid property.
            CmFilter testObj1 = new CmFilter();
            CmFilter testObj2 = new CmFilter();

            m_fdoCache.LangProject.FiltersOC.Add(testObj1);
            m_fdoCache.LangProject.FiltersOC.Add(testObj2);

            // Set a guid property for the 2nd test object
            // that is equal to the first test object's guid.
            m_sda.SetGuid(testObj2.Hvo, (int)CmFilter.CmFilterTags.kflidApp, testObj1.Guid);

            // This should not delete guid from the cache's internal object guid cache.
            m_da.UpdatePropIfCached(testObj2.Hvo, testObj2.FieldId,
                                    (int)CellarModuleDefns.kcptGuid, 0);

            // Make sure we still can create the first test object from it's guid.
            Assert.AreEqual(testObj1.Hvo, m_sda.get_ObjFromGuid(testObj1.Guid));
        }
Ejemplo n.º 3
0
        public void GuidProp()
        {
            CheckDisposed();
            Guid guidNew = m_ISilDataAccess.get_GuidProp(1113, 2223);

            Assert.AreEqual(Guid.Empty, guidNew);
            Assert.IsFalse(m_ISilDataAccess.IsDirty());

            Guid guid = new Guid(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);

            m_ISilDataAccess.SetGuid(1113, 2223, guid);
            guidNew = m_ISilDataAccess.get_GuidProp(1113, 2223);
            Assert.AreEqual(guid, guidNew);
            Assert.IsTrue(m_ISilDataAccess.IsDirty());

            Guid guid2 = new Guid(10, 12, 13, 14, 15, 16, 17, 18, 19, 110, 111);

            m_ISilDataAccess.SetGuid(1113, 2223, guid2);
            guidNew = m_ISilDataAccess.get_GuidProp(1113, 2223);
            Assert.AreEqual(guid2, guidNew);
            Assert.IsTrue(m_ISilDataAccess.IsDirty());

            CheckProp(1113, 2223, guid2, CellarModuleDefns.kcptGuid);
        }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="hvo"></param>
 /// <param name="tag"></param>
 /// <param name="uid"></param>
 public void SetGuid(int hvo, int tag, Guid uid)
 {
     VerifyUpdate(hvo, tag);
     m_sda.SetGuid(hvo, tag, uid);
 }
Ejemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Handles the flids for basic data (bool, string, int, etc.)
        /// </summary>
        /// <param name="thisFlid">The object type flid.</param>
        /// <param name="flidType">The owning flid type.</param>
        /// <param name="hvoSrc">The hvo of the source object.</param>
        /// <param name="hvoNew">The hvo of the new object.</param>
        /// ------------------------------------------------------------------------------------
        private void HandleBasicOrStringFlid(int thisFlid, int flidType, int hvoSrc, int hvoNew)
        {
            // Basic and String properties are copied
            switch (flidType)
            {
            // Basic Properties follow

            case (int)CellarPropertyType.Binary:
                string flidName = m_mdc.GetFieldName(thisFlid);
                if (flidName == "Rules" || flidName == "StyleRules")
                {
                    CopyBinaryAsTextProps(thisFlid, hvoSrc, hvoNew);
                }
                else
                {
                    CopyBinaryAsBinary(thisFlid, hvoSrc, hvoNew);
                }
                break;

            case (int)CellarPropertyType.Boolean:
                // Copy boolean value
                m_sda.SetBoolean(hvoNew, thisFlid, m_sda.get_BooleanProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.Guid:
                // Copy guid value
                // These are currently used as the ID for an application, or a version number, or a Scripture Check ID)
                m_sda.SetGuid(hvoNew, thisFlid, m_sda.get_GuidProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.GenDate:                     // Fall through, since a GenDate is an int.
            case (int)CellarPropertyType.Integer:
                // Copy integer value
                m_sda.SetInt(hvoNew, thisFlid, m_sda.get_IntProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.Time:
                // Copy time value
                m_sda.SetTime(hvoNew, thisFlid, m_sda.get_TimeProp(hvoSrc, thisFlid));
                break;

            // String Properties follow

            case (int)CellarPropertyType.String:
                // Copy string value
                // Review: Please check these next three!
                m_sda.SetString(hvoNew, thisFlid, m_sda.get_StringProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.Unicode:
                // Copy Unicode string
                m_sda.set_UnicodeProp(hvoNew, thisFlid, m_sda.get_UnicodeProp(hvoSrc, thisFlid));
                break;

            case (int)CellarPropertyType.MultiString:                     // Fall through
            case (int)CellarPropertyType.MultiUnicode:
                ITsMultiString sMulti = m_sda.get_MultiStringProp(hvoSrc, thisFlid);
                for (int i = 0; i < sMulti.StringCount; i++)
                {
                    int       ws;
                    ITsString tss = sMulti.GetStringFromIndex(i, out ws);
                    m_sda.SetMultiStringAlt(hvoNew, thisFlid, ws, tss);
                }
                break;

            default:
                throw new FDOInvalidFieldTypeException(String.Format("CopyObject: Unsupported field type {0}.", flidType));
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Change a GUID property of an object.
 /// The caller should also call PropChanged to notify interested parties,
 /// except where the change is being made to a newly created object.
 ///</summary>
 /// <param name='hvo'> </param>
 /// <param name='tag'> </param>
 /// <param name='uid'> </param>
 public virtual void SetGuid(int hvo, int tag, Guid uid)
 {
     m_baseSda.SetGuid(hvo, tag, uid);
 }