本文整理汇总了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;
}
示例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;
}