Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This is the heart of CopyObject Pass 2.
        /// Sets the references recursively. Needs to go down recursively into
        /// all of the source object's owned properties looking for Reference
        /// properties, since those owned properties will have just been copied too.
        /// </summary>
        /// <param name="source">The source.</param>
        /// ------------------------------------------------------------------------------------
        private void SetReferencesRecursively(ICmObject source)
        {
            // Get the copy of our source object in which to set references.
            ICmObject newObj;
            int       hvoSrc = source.Hvo;

            if (!m_sourceToCopyMap.TryGetValue(hvoSrc, out newObj))
            {
                throw new ArgumentOutOfRangeException("source", "Can't find copy of original object in copy map.");
            }

            if (source is ICloneableCmObject)
            {
                return;                 // Assume that the object handled this itself
            }
            // TODO: Copy references from source object to copied object unless reference is to something in the sourceToCopyMap
            // in that case replace it with a reference to the copied version.
            // We'll need to go down inside of all owned objects to do this too, since they were just copied.
            int srcClsID = source.ClassID;
            int hvoCopy  = newObj.Hvo;

            int[] srcFlids = GetAllFieldsFromClassId(srcClsID);

            // Clone each owned flid and copy basic properties
            for (int i = 0; i < srcFlids.Length; i++)
            {
                int thisFlid = srcFlids[i];
                // If thisFlid is part of CmObject, this Flid of copied object has
                //   already been correctly set on creation.
                // Also skip virtual fields; let the object handle its own virtuals.
                if (thisFlid < 200 || m_mdc.get_IsVirtual(thisFlid))
                {
                    continue;
                }

                // Skip basic/string properties this pass
                int flidType = m_mdc.GetFieldType(thisFlid);
                if (flidType < (int)CellarPropertyType.MinObj)
                {
                    continue;
                }

                // Only have reference and owned props left
                if (m_cache.IsReferenceProperty(thisFlid))
                {
                    SetReferencesForReferenceFlid(thisFlid, flidType, hvoSrc, hvoCopy);
                }
                else
                {
                    SetReferencesForOwnedFlid(thisFlid, flidType, hvoSrc);
                }
            }
        }
Esempio n. 2
0
        private static Dictionary <string, List <PropertyInfo> > CacheBasicProperties(IFwMetaDataCacheManaged mdc)
        {
            var cachedBasicProperties = new Dictionary <string, List <PropertyInfo> >();

            foreach (var classId in mdc.GetClassIds())
            {
                var className = mdc.GetClassName(classId);
                List <PropertyInfo> basicProps;
                if (!cachedBasicProperties.TryGetValue(className, out basicProps))
                {
                    basicProps = new List <PropertyInfo>();
                    cachedBasicProperties.Add(className, basicProps);
                }
                basicProps.AddRange(mdc.GetFields(classId, className != "CmObject", (int)CellarPropertyTypeFilter.AllBasic).Select(propId => new PropertyInfo
                {
                    m_propertyName = mdc.GetFieldName(propId),
                    m_propertyType = (CellarPropertyType)mdc.GetFieldType(propId),
                    m_isCustom     = mdc.IsCustom(propId),
                    m_isVirtual    = mdc.get_IsVirtual(propId)
                }));
                if (basicProps.Count == 0)
                {
                    cachedBasicProperties.Remove(className);
                }
            }
            return(cachedBasicProperties);
        }
Esempio n. 3
0
 /// <summary> </summary>
 /// <param name='luFlid'> </param>
 /// <returns></returns>
 public virtual bool get_IsVirtual(int luFlid)
 {
     return(m_metaDataCache.get_IsVirtual(luFlid));
 }
		private static Dictionary<string, List<PropertyInfo>> CacheBasicProperties(IFwMetaDataCacheManaged mdc)
		{
			var cachedBasicProperties = new Dictionary<string, List<PropertyInfo>>();
			foreach (var classId in mdc.GetClassIds())
			{
				var className = mdc.GetClassName(classId);
				List<PropertyInfo> basicProps;
				if (!cachedBasicProperties.TryGetValue(className, out basicProps))
				{
					basicProps = new List<PropertyInfo>();
					cachedBasicProperties.Add(className, basicProps);
				}
				basicProps.AddRange(mdc.GetFields(classId, className != "CmObject", (int)CellarPropertyTypeFilter.AllBasic).Select(propId => new PropertyInfo
					{
						m_propertyName = mdc.GetFieldName(propId),
						m_propertyType = (CellarPropertyType)mdc.GetFieldType(propId),
						m_isCustom = mdc.IsCustom(propId),
						m_isVirtual = mdc.get_IsVirtual(propId)
					}));
				if (basicProps.Count == 0)
					cachedBasicProperties.Remove(className);
			}
			return cachedBasicProperties;
		}