当前位置: 首页>>代码示例>>C#>>正文


C# Slice.GetFlid方法代码示例

本文整理汇总了C#中Slice.GetFlid方法的典型用法代码示例。如果您正苦于以下问题:C# Slice.GetFlid方法的具体用法?C# Slice.GetFlid怎么用?C# Slice.GetFlid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slice的用法示例。


在下文中一共展示了Slice.GetFlid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertObjectIfPossible

		/// <returns>
		/// 'true' means we found a suitable place to insert an object,
		/// not that it was actually inserted. It may, or may not, have been inserted in this case.
		/// 'false' means no suitable place was found, so the calling code can try other locations.
		/// </returns>
		private bool InsertObjectIfPossible(int newObjectClassId, int ownerClassId, string fieldName, Slice slice, string recomputeVirtual)
		{
			if ((ownerClassId > 0 && IsOrInheritsFrom((slice.Object.ClassID), ownerClassId)) // For adding senses using the simple edit mode, no matter where the cursor is.
				|| slice.Object == Object
				//|| slice.Object == ContainingDataTree.Root)
				|| slice.Object.Equals(ContainingDataTree.Root)) // Other cases.
			{
				// The slice's object has an acceptable type provided it implements the required field.
				// See if the current slice's object has the field named.
				int flid = slice.GetFlid(fieldName);
				var mdc = Cache.MetaDataCacheAccessor as IFwMetaDataCacheManaged;
				int flidT = ContainingDataTree.GetFlidIfPossible(ownerClassId, fieldName, mdc);
				if (flidT != 0 && flid != flidT)
					flid = flidT;
				if (flid == 0)
					return false;
				// Found a suitable slice. Do the insertion.
				int insertionPosition;		// causes return false if not changed.
				if (m_cache.IsReferenceProperty(flid))
				{
					insertionPosition = InsertObjectIntoVirtualBackref(Cache, m_mediator, slice.Object.Hvo,
						newObjectClassId, flid);
				}
				else
				{
					insertionPosition = slice.InsertObject(flid, newObjectClassId);
				}
				if (insertionPosition < 0)
					return insertionPosition == -2;		// -2 keeps dlg for adding subPOSes from firing for each slice when cancelled.
				if (String.IsNullOrEmpty(recomputeVirtual))
					return true;
				// Figure the things to recompute.
				string[] parts = recomputeVirtual.Split('.');
				if (parts.Length != 2)
				{
					Debug.Assert(parts.Length == 2);
					return true; // but fairly harmless to ignore
				}

				return true;
			}
			return false;
		}
开发者ID:bbriggs,项目名称:FieldWorks,代码行数:48,代码来源:Slice.cs

示例2: InsertObjectIfPossible

		/// <summary>
		///
		/// </summary>
		/// <param name="newObjectClassId"></param>
		/// <param name="ownerClassId"></param>
		/// <param name="fieldName"></param>
		/// <param name="slice"></param>
		/// <param name="recomputeVirtual"></param>
		/// <returns></returns>
		/// <remarks>
		/// 'true' means we found a suitable place to insert an object,
		/// not that it was actually inserted. It may, or may not, have been inserted in this case.
		/// 'false' means no suitable place was found, so the calling code can try other locations.
		/// </remarks>
		private bool InsertObjectIfPossible(uint newObjectClassId, uint ownerClassId, string fieldName, Slice slice, string recomputeVirtual)
		{
			if ((ownerClassId > 0 && IsOrInheritsFrom((uint)(slice.Object.ClassID), ownerClassId)) // For adding senses using the simple edit mode, no matter where the cursor is.
				|| slice.Object == Object
				//|| slice.Object == ContainingDataTree.Root)
				|| slice.Object.Equals(ContainingDataTree.Root)) // Other cases.
			{
				// The slice's object has an acceptable type provided it implements the required field.
				// See if the current slice's object has the field named.
				uint flid = slice.GetFlid(fieldName);
				uint flidT = m_cache.MetaDataCacheAccessor.GetFieldId2((uint)ownerClassId, fieldName, true);
				if (flidT != 0 && flid != flidT)
					flid = flidT;
				if (flid == 0)
					return false;
				// Found a suitable slice. Do the insertion.
				IFwMetaDataCache mdc = Cache.MetaDataCacheAccessor;
				int insertionPosition = -1;		// causes return false if not changed.
				if (m_cache.IsReferenceProperty((int)flid))
				{
					insertionPosition = Slice.InsertObjectIntoVirtualBackref(Cache, m_mediator,
						Cache.VwCacheDaAccessor.GetVirtualHandlerId((int)flid), slice.Object.Hvo,
						newObjectClassId, ownerClassId, flid);
				}
				else
				{
					insertionPosition = slice.InsertObject(flid, newObjectClassId);
				}
				if (insertionPosition < 0)
					return insertionPosition == -2;		// -2 keeps dlg for adding subPOSes from firing for each slice when cancelled.
				if (String.IsNullOrEmpty(recomputeVirtual))
					return true;
				// Figure the things to recompute.
				int hvoOwner = slice.Object.Hvo;
				string[] parts = recomputeVirtual.Split('.');
				if (parts.Length != 2)
				{
					Debug.Assert(parts.Length == 2);
					return true; // but fairly harmless to ignore
				}
				uint clidVirtual = mdc.GetClassId(parts[0]);
				int flidVirtual = (int)mdc.GetFieldId2(clidVirtual, parts[1], true);
				ISilDataAccess sda = Cache.MainCacheAccessor;
				int chvo = sda.get_VecSize(hvoOwner, (int)flid);
				IVwVirtualHandler vh = Cache.VwCacheDaAccessor.GetVirtualHandlerId(flidVirtual);
				int typeVirtual = mdc.GetFieldType((uint)flidVirtual);
				if (vh == null)
					return true; // not a virtual property.
				for (int i = insertionPosition + 1; i < chvo; i++)
				{
					RecomputeVirtuals(sda.get_VecItem(hvoOwner, (int)flid, i), clidVirtual, flidVirtual, typeVirtual, mdc, sda, vh);
				}

				return true;
			}
			return false;
		}
开发者ID:sillsdev,项目名称:WorldPad,代码行数:71,代码来源:Slice.cs


注:本文中的Slice.GetFlid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。