Example #1
0
        public override bool Equals(object obj)
        {
            if (!(obj is ClidFieldnameKey))
            {
                return(false);
            }

            ClidFieldnameKey cfk = (ClidFieldnameKey)obj;

            return((cfk.m_clid == m_clid) &&
                   (cfk.m_fieldname == m_fieldname));
        }
Example #2
0
		private void LoadObject(XmlNode objectNode, int hvo, uint clid, Dictionary<int, uint> objects)
		{
#if COUNTMethodhits
		m_loadObjectCount++;
#endif
			// Optimize by looping over the child nodes,
			// and dealing with relevant flid.
			// The idea is that most objects will only have a subset of fields filled in.
#if false
			foreach (XmlNode fieldNode in objectNode.ChildNodes)
			{
#else
			XmlNodeList nodeList = objectNode.ChildNodes;
			for (int i = 0; i < nodeList.Count; ++i)
			{
				XmlNode fieldNode = nodeList[i]; // Item(i);
#endif
				string fieldName = fieldNode.Name;
				int idx = fieldName.IndexOfAny(new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9' });
				fieldName = fieldName.Substring(0, idx);
				ClidFieldnameKey cfk = new ClidFieldnameKey(clid, fieldName);
				uint uflid = 0;
				if (m_cachedFlids.ContainsKey(cfk))
				{
					uflid = m_cachedFlids[cfk];
				}
				else
				{
					uflid = m_metaDataCache.GetFieldId2(clid, fieldName, true);
					m_cachedFlids[cfk] = uflid;
				}

				int flidType = m_metaDataCache.GetFieldType(uflid);
				uint ownedClid;
				int ownedHvo;
				switch (flidType)
				{
					case (int)CellarModuleDefns.kcptBoolean:
						// <System18><Boolean val="true"/></System18>
						m_realDataCache.CacheBooleanProp(hvo, (int)uflid, bool.Parse(fieldNode.FirstChild.Attributes["val"].Value));
						break;
					case (int)CellarModuleDefns.kcptInteger:
						// <Type18><Integer val="1"/></Type18>
						m_realDataCache.CacheIntProp(hvo, (int)uflid, Int32.Parse(fieldNode.FirstChild.Attributes["val"].Value));
						break;
					case (int)CellarModuleDefns.kcptNumeric:
						break;
					case (int)CellarModuleDefns.kcptFloat:
						break;
					case (int)CellarModuleDefns.kcptTime:
						// <LastModified24><Time val="2005-11-18 02:48:33.000"/></LastModified24>
						DateTime valTime = DateTime.Parse(fieldNode.FirstChild.Attributes["val"].Value);
						m_realDataCache.CacheTimeProp(hvo, (int)uflid, valTime.Ticks);
						break;
					case (int)CellarModuleDefns.kcptGuid:
						if (uflid != (uint)CmObjectFields.kflidCmObject_Guid)
						{
							// <App18><Guid val="5EA62D01-7A78-11D4-8078-0000C0FB81B5"/></App18>
							string uid = fieldNode.FirstChild.Attributes["val"].Value;
							m_realDataCache.CacheGuidProp(hvo, (int)uflid, new Guid(uid));
						}
						break;
					case (int)CellarModuleDefns.kcptImage:
						break;
					case (int)CellarModuleDefns.kcptGenDate:
						// <DateOfEvent4006><GenDate val=\"193112111\" /></DateOfEvent4006>
						break;
					case (int)CellarModuleDefns.kcptBinary:
						// <Details18><Binary>03000000</Binary></Details18>
						// <Details18><Binary>05000000\r\n</Binary></Details18>
						break;
					case (int)CellarModuleDefns.kcptString:
					case (int)CellarModuleDefns.kcptBigString:
						// "<Str><Run ws=\"eZPI\">Te mgyeey ne la Benit nuu Pwert. Za men gun men inbitar xmig men ne la Jasint nuu San José. Za Benit. Weey Benit mël. Weey Benit mëlbyuu ne ygued Benit lo xmig Benit, Jasint. Chene wdxiin Benit ruxyuu Jasint, re Benit:</Run></Str>"
						foreach (XmlNode strNode in fieldNode.ChildNodes)
						{
							ITsString tssStr = m_tsf.CreateFromStr(strNode);
							m_realDataCache.CacheStringProp(hvo, (int)uflid, tssStr);
						}
						// CacheStringProp(hvo, tag, tss);
						break;
					case (int)CellarModuleDefns.kcptMultiString: // <AStr>
					case (int)CellarModuleDefns.kcptMultiBigString: // <AStr
						foreach (XmlNode aStrAlt in fieldNode.ChildNodes)
						{
							int wsAStr;
							ITsString tssAlt = m_tsf.CreateFromAStr(aStrAlt, out wsAStr);
							m_realDataCache.CacheStringAlt(hvo, (int)uflid, wsAStr, tssAlt);
						}
						break;
					case (int)CellarModuleDefns.kcptUnicode: // Fall through.
					case (int)CellarModuleDefns.kcptBigUnicode:
						string unicodeText = fieldNode.FirstChild.InnerText;
						m_realDataCache.CacheUnicodeProp(hvo, (int)uflid, unicodeText, unicodeText.Length);
						break;
					case (int)CellarModuleDefns.kcptMultiUnicode: // <AUni>
						foreach (XmlNode uniNode in fieldNode.ChildNodes)
						{
							int ws = m_wsCache[uniNode.Attributes["ws"].Value];
							string uniText = uniNode.InnerText;
							m_realDataCache.CacheStringAlt(hvo, (int)uflid, ws, m_itsf.MakeString(uniText, ws));
						}
						break;
					case (int)CellarModuleDefns.kcptMultiBigUnicode:
						break;

					// Cases for regular objects.
					case (int)CellarModuleDefns.kcptOwningAtom:
						XmlNode atomicOwnedObject = fieldNode.FirstChild;
						ownedHvo = LoadCmObjectProperties(atomicOwnedObject, hvo, uflid, 0, out ownedClid, objects);
						LoadObject(atomicOwnedObject, ownedHvo, ownedClid, objects);
						m_realDataCache.CacheObjProp(hvo, (int)uflid, ownedHvo);
						break;
					case (int)CellarModuleDefns.kcptReferenceAtom:
						/* Some are simple Guid links, but others contain more info.
						<Category5059>
							<Link target="I751B8DE1-089B-42B1-A35E-62CF838A27A3" ws="en" abbr="N" name="noun"/>
						</Category5059>
						<Morph5112>
							<Link target="I9370DD7D-978D-484D-B304-B5D4700BAA30"/>
						</Morph5112>
						*/
						// Defer caching references, until all objects are loaded.
						m_delayedAtomicReferences[new HvoFlidKey(hvo, uflid)] = fieldNode.FirstChild;
						break;
					case (int)CellarModuleDefns.kcptOwningCollection: // Fall through.
					case (int)CellarModuleDefns.kcptOwningSequence:
						List<int> hvos = new List<int>();
						int newOrd = 0;
						foreach (XmlNode obj in fieldNode.ChildNodes)
						{
							ownedHvo = LoadCmObjectProperties(obj, hvo, uflid, newOrd, out ownedClid, objects);
							LoadObject(obj, ownedHvo, ownedClid, objects);
							hvos.Add(ownedHvo);
							if (flidType == (int)CellarModuleDefns.kcptOwningSequence)
								newOrd++;
						}
						m_realDataCache.CacheVecProp(hvo, (int)uflid, hvos.ToArray(), hvos.Count);
						break;
					case (int)CellarModuleDefns.kcptReferenceCollection: // Fall through.
					case (int)CellarModuleDefns.kcptReferenceSequence:
						// <Link target="ID75F7FB5-BABD-4D60-B57F-E188BEF264B7" />
						// Defer caching references, until all objects are loaded.
						List<XmlNode> list = new List<XmlNode>();
						m_delayedVecterReferences[new HvoFlidKey(hvo, uflid)] = list;
						foreach (XmlNode linkNode in fieldNode.ChildNodes)
							list.Add(linkNode);
						break;
				}
			}
		}
	}
Example #3
0
        private void LoadObject(XmlNode objectNode, int hvo, uint clid, Dictionary <int, uint> objects)
        {
#if COUNTMethodhits
            m_loadObjectCount++;
#endif
            // Optimize by looping over the child nodes,
            // and dealing with relevant flid.
            // The idea is that most objects will only have a subset of fields filled in.
#if false
            foreach (XmlNode fieldNode in objectNode.ChildNodes)
            {
#else
            XmlNodeList nodeList = objectNode.ChildNodes;
            for (int i = 0; i < nodeList.Count; ++i)
            {
                XmlNode fieldNode = nodeList[i];                 // Item(i);
#endif
                string fieldName = fieldNode.Name;
                int    idx       = fieldName.IndexOfAny(new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9' });
                fieldName = fieldName.Substring(0, idx);
                ClidFieldnameKey cfk   = new ClidFieldnameKey(clid, fieldName);
                uint             uflid = 0;
                if (m_cachedFlids.ContainsKey(cfk))
                {
                    uflid = m_cachedFlids[cfk];
                }
                else
                {
                    uflid = m_metaDataCache.GetFieldId2(clid, fieldName, true);
                    m_cachedFlids[cfk] = uflid;
                }

                int  flidType = m_metaDataCache.GetFieldType(uflid);
                uint ownedClid;
                int  ownedHvo;
                switch (flidType)
                {
                case (int)CellarModuleDefns.kcptBoolean:
                    // <System18><Boolean val="true"/></System18>
                    m_realDataCache.CacheBooleanProp(hvo, (int)uflid, bool.Parse(fieldNode.FirstChild.Attributes["val"].Value));
                    break;

                case (int)CellarModuleDefns.kcptInteger:
                    // <Type18><Integer val="1"/></Type18>
                    m_realDataCache.CacheIntProp(hvo, (int)uflid, Int32.Parse(fieldNode.FirstChild.Attributes["val"].Value));
                    break;

                case (int)CellarModuleDefns.kcptNumeric:
                    break;

                case (int)CellarModuleDefns.kcptFloat:
                    break;

                case (int)CellarModuleDefns.kcptTime:
                    // <LastModified24><Time val="2005-11-18 02:48:33.000"/></LastModified24>
                    DateTime valTime = DateTime.Parse(fieldNode.FirstChild.Attributes["val"].Value);
                    m_realDataCache.CacheTimeProp(hvo, (int)uflid, valTime.Ticks);
                    break;

                case (int)CellarModuleDefns.kcptGuid:
                    if (uflid != (uint)CmObjectFields.kflidCmObject_Guid)
                    {
                        // <App18><Guid val="5EA62D01-7A78-11D4-8078-0000C0FB81B5"/></App18>
                        string uid = fieldNode.FirstChild.Attributes["val"].Value;
                        m_realDataCache.CacheGuidProp(hvo, (int)uflid, new Guid(uid));
                    }
                    break;

                case (int)CellarModuleDefns.kcptImage:
                    break;

                case (int)CellarModuleDefns.kcptGenDate:
                    // <DateOfEvent4006><GenDate val=\"193112111\" /></DateOfEvent4006>
                    break;

                case (int)CellarModuleDefns.kcptBinary:
                    // <Details18><Binary>03000000</Binary></Details18>
                    // <Details18><Binary>05000000\r\n</Binary></Details18>
                    break;

                case (int)CellarModuleDefns.kcptString:
                case (int)CellarModuleDefns.kcptBigString:
                    // "<Str><Run ws=\"eZPI\">Te mgyeey ne la Benit nuu Pwert. Za men gun men inbitar xmig men ne la Jasint nuu San José. Za Benit. Weey Benit mël. Weey Benit mëlbyuu ne ygued Benit lo xmig Benit, Jasint. Chene wdxiin Benit ruxyuu Jasint, re Benit:</Run></Str>"
                    foreach (XmlNode strNode in fieldNode.ChildNodes)
                    {
                        ITsString tssStr = m_tsf.CreateFromStr(strNode);
                        m_realDataCache.CacheStringProp(hvo, (int)uflid, tssStr);
                    }
                    // CacheStringProp(hvo, tag, tss);
                    break;

                case (int)CellarModuleDefns.kcptMultiString:                         // <AStr>
                case (int)CellarModuleDefns.kcptMultiBigString:                      // <AStr
                    foreach (XmlNode aStrAlt in fieldNode.ChildNodes)
                    {
                        int       wsAStr;
                        ITsString tssAlt = m_tsf.CreateFromAStr(aStrAlt, out wsAStr);
                        m_realDataCache.CacheStringAlt(hvo, (int)uflid, wsAStr, tssAlt);
                    }
                    break;

                case (int)CellarModuleDefns.kcptUnicode:                         // Fall through.
                case (int)CellarModuleDefns.kcptBigUnicode:
                    string unicodeText = fieldNode.FirstChild.InnerText;
                    m_realDataCache.CacheUnicodeProp(hvo, (int)uflid, unicodeText, unicodeText.Length);
                    break;

                case (int)CellarModuleDefns.kcptMultiUnicode:                         // <AUni>
                    foreach (XmlNode uniNode in fieldNode.ChildNodes)
                    {
                        int    ws      = m_wsCache[uniNode.Attributes["ws"].Value];
                        string uniText = uniNode.InnerText;
                        m_realDataCache.CacheStringAlt(hvo, (int)uflid, ws, m_itsf.MakeString(uniText, ws));
                    }
                    break;

                case (int)CellarModuleDefns.kcptMultiBigUnicode:
                    break;

                // Cases for regular objects.
                case (int)CellarModuleDefns.kcptOwningAtom:
                    XmlNode atomicOwnedObject = fieldNode.FirstChild;
                    ownedHvo = LoadCmObjectProperties(atomicOwnedObject, hvo, uflid, 0, out ownedClid, objects);
                    LoadObject(atomicOwnedObject, ownedHvo, ownedClid, objects);
                    m_realDataCache.CacheObjProp(hvo, (int)uflid, ownedHvo);
                    break;

                case (int)CellarModuleDefns.kcptReferenceAtom:
                    /* Some are simple Guid links, but others contain more info.
                     * <Category5059>
                     *      <Link target="I751B8DE1-089B-42B1-A35E-62CF838A27A3" ws="en" abbr="N" name="noun"/>
                     * </Category5059>
                     * <Morph5112>
                     *      <Link target="I9370DD7D-978D-484D-B304-B5D4700BAA30"/>
                     * </Morph5112>
                     */
                    // Defer caching references, until all objects are loaded.
                    m_delayedAtomicReferences[new HvoFlidKey(hvo, uflid)] = fieldNode.FirstChild;
                    break;

                case (int)CellarModuleDefns.kcptOwningCollection:                         // Fall through.
                case (int)CellarModuleDefns.kcptOwningSequence:
                    List <int> hvos   = new List <int>();
                    int        newOrd = 0;
                    foreach (XmlNode obj in fieldNode.ChildNodes)
                    {
                        ownedHvo = LoadCmObjectProperties(obj, hvo, uflid, newOrd, out ownedClid, objects);
                        LoadObject(obj, ownedHvo, ownedClid, objects);
                        hvos.Add(ownedHvo);
                        if (flidType == (int)CellarModuleDefns.kcptOwningSequence)
                        {
                            newOrd++;
                        }
                    }
                    m_realDataCache.CacheVecProp(hvo, (int)uflid, hvos.ToArray(), hvos.Count);
                    break;

                case (int)CellarModuleDefns.kcptReferenceCollection:                         // Fall through.
                case (int)CellarModuleDefns.kcptReferenceSequence:
                    // <Link target="ID75F7FB5-BABD-4D60-B57F-E188BEF264B7" />
                    // Defer caching references, until all objects are loaded.
                    List <XmlNode> list = new List <XmlNode>();
                    m_delayedVecterReferences[new HvoFlidKey(hvo, uflid)] = list;
                    foreach (XmlNode linkNode in fieldNode.ChildNodes)
                    {
                        list.Add(linkNode);
                    }
                    break;
                }
            }
        }
    }