本文整理汇总了C#中SIL.FieldWorks.FDO.FdoCache.IsValidObject方法的典型用法代码示例。如果您正苦于以下问题:C# FdoCache.IsValidObject方法的具体用法?C# FdoCache.IsValidObject怎么用?C# FdoCache.IsValidObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.FDO.FdoCache
的用法示例。
在下文中一共展示了FdoCache.IsValidObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTwficWs
/// <summary>
/// get the ws at the twfic's BeginOffset in its paragraph.
/// </summary>
/// <param name="cache">The cache.</param>
/// <param name="hvoTwfic">The hvo twfic.</param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public static int GetTwficWs(FdoCache cache, int hvoTwfic)
{
Debug.Assert(cache.IsValidObject(hvoTwfic, CmBaseAnnotation.kClassId),
String.Format("expected valid hvo({0}).", hvoTwfic));
if (hvoTwfic <= 0 && !cache.IsDummyObject(hvoTwfic))
throw new ArgumentException(String.Format("expected valid hvo({0}).", hvoTwfic));
int hvoPara = cache.GetObjProperty(hvoTwfic,
(int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginObject);
int ichBeginOffset = cache.GetIntProperty(hvoTwfic,
(int)CmBaseAnnotation.CmBaseAnnotationTags.kflidBeginOffset);
int ws = GetWsAtParaOffset(cache, hvoPara, ichBeginOffset);
return ws;
}
示例2: DeleteRedundantCapitalizedWordform
/// <summary>
/// If hvoWordform is the hvo of a capitalized wordform which has no useful information,
/// delete it. It is considered useless if
/// - it has no occurrences
/// - it has no anlyses
/// - it doesn't have known incorrect spelling status.
/// Note that the argument may be some other kind of object (typically a WfiAnalysis or WfiGloss).
/// If so do nothing.
/// </summary>
public static void DeleteRedundantCapitalizedWordform(FdoCache cache, int hvoWordform)
{
if (cache.GetClassOfObject(hvoWordform) != WfiWordform.kclsidWfiWordform)
return;
if (cache.GetVectorProperty(hvoWordform, OccurrencesFlid(cache), true).Length != 0)
return;
if (cache.IsValidObject(hvoWordform))
{
// If it's real it might have analyses etc.
WfiWordform wf = (WfiWordform) CmObject.CreateFromDBObject(cache, hvoWordform);
if (wf.AnalysesOC.Count > 0)
return;
// Arguably we should keep it for known correct spelling status. However, if it's ever been
// confirmed as an analysis, even temporarily, it will have that.
if (wf.SpellingStatus == (int)SpellingStatusStates.incorrect)
return;
}
foreach (int ws in cache.LangProject.CurVernWssRS.HvoArray)
{
CaseFunctions cf = new CaseFunctions(cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws).IcuLocale);
string text = cache.GetMultiStringAlt(hvoWordform, (int) WfiWordformTags.kflidForm, ws).Text;
if (!String.IsNullOrEmpty(text) && cf.StringCase(text) == StringCaseStatus.allLower)
return;
}
cache.DeleteObject(hvoWordform);
}
示例3: TryDeleteWordforms
/// <summary>
/// Try deleting wordforms when none of the given paragraphs have annotations (including dummies)
/// with instances of the wordforms.
/// </summary>
/// <param name="cache"></param>
/// <param name="wfIdsToTry">wordform ids to try to delete</param>
/// <param name="hvoParasInView">the paragraphs that may have dummy annotations with instances of those wordforms</param>
/// <param name="delObjIds">the wordforms that actually got deleted.</param>
/// <returns>true if we deleted a wordform</returns>
public static bool TryDeleteWordforms(FdoCache cache, int[] wfIdsToTry, int[] hvoParasInView, out Set<int> delObjIds)
{
int vtagSegments = StTxtPara.SegmentsFlid(cache);
IVwVirtualHandler vh;
cache.TryGetVirtualHandler(vtagSegments, out vh);
FDOSequencePropertyVirtualHandler segmentsVh = vh as FDOSequencePropertyVirtualHandler;
delObjIds = new Set<int>(wfIdsToTry.Length);
foreach (int wfid in wfIdsToTry)
{
if (!cache.IsValidObject(wfid))
continue; // already been deleted, probably as a consequence of annotation.DeleteUnderlyingObject.
ICmObject obj = CmObject.CreateFromDBObject(cache, wfid, false);
if (obj.CanDelete)
{
// make a final check to see if any of the segment forms in the given paragraphs contain an
// instance to this wordform. If not, it's safe to delete it.
if (!WordformHasOccurrenceInParas(cache, wfid, hvoParasInView, segmentsVh))
delObjIds.Add(wfid);
}
}
foreach (WfiWordform wf in new FdoObjectSet<WfiWordform>(cache, delObjIds.ToArray(), false, typeof(WfiWordform)))
{
wf.DeleteUnderlyingObject();
}
return delObjIds.Count != 0;
}