本文整理汇总了C#中SIL.FieldWorks.FDO.FdoCache.GetClassOfObject方法的典型用法代码示例。如果您正苦于以下问题:C# FdoCache.GetClassOfObject方法的具体用法?C# FdoCache.GetClassOfObject怎么用?C# FdoCache.GetClassOfObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.FieldWorks.FDO.FdoCache
的用法示例。
在下文中一共展示了FdoCache.GetClassOfObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetWordformFromWag
/// <summary>
/// Get a wordform from an HVO that may be a WfiWordform, WfiAnalysis, or WfiGloss (or 0).
/// Answer 0 if arguent is zero, fail if it is some other class.
/// </summary>
public static int GetWordformFromWag(FdoCache cache, int cbaInstanceOf)
{
int hvoWordform = 0;
if (cbaInstanceOf != 0)
{
int classid = cache.GetClassOfObject(cbaInstanceOf);
switch (classid)
{
case WfiWordform.kclsidWfiWordform:
hvoWordform = cbaInstanceOf;
break;
case WfiAnalysis.kclsidWfiAnalysis:
hvoWordform = cache.GetOwnerOfObject(cbaInstanceOf);
break;
case WfiGloss.kclsidWfiGloss:
int hvoAnalysis = cache.GetOwnerOfObject(cbaInstanceOf);
hvoWordform = cache.GetOwnerOfObject(hvoAnalysis);
break;
default:
Debug.Fail("Actual cba (" + cbaInstanceOf + "): Class of InstanceOf (" +
classid + ") is not WfiWordform, WfiAnalysis, or WfiGloss.");
break;
}
}
return hvoWordform;
}
示例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: GetFootnoteFromProps
/// ------------------------------------------------------------------------------------
/// <summary>
/// Gets footnote hvo from reference in text properties
/// </summary>
/// <param name="cache"></param>
/// <param name="tprops"></param>
/// <returns>Hvo of the footnote that was found or 0 if none was found</returns>
/// ------------------------------------------------------------------------------------
protected static int GetFootnoteFromProps(FdoCache cache, ITsTextProps tprops)
{
string footnoteRef =
tprops.GetStrPropValue((int)FwTextPropType.ktptObjData);
if (footnoteRef != null)
{
// first char. of strData is type code - GUID will follow it.
Guid objGuid = MiscUtils.GetGuidFromObjData(footnoteRef.Substring(1));
int hvo = cache.GetIdFromGuid(objGuid);
if (hvo > 0 && cache.GetClassOfObject(hvo) == StFootnote.kClassId)
return hvo;
}
return 0;
}
示例4: RefreshCacheForParagraph
/// ------------------------------------------------------------------------------------
/// <summary>
/// Refreshes cache for all footnotes in the StText containing the paragraph. We only
/// use this method when verses of a paragraph are changed - this will only happen on
/// content paragraphs of a ScrSection.
/// </summary>
/// <param name="cache"></param>
/// <param name="hvoObj"></param>
/// ------------------------------------------------------------------------------------
internal static void RefreshCacheForParagraph(FdoCache cache, int hvoObj)
{
int hvoPara = hvoObj;
if (cache.GetClassOfObject(hvoObj) == CmTranslation.kClassId)
hvoPara = cache.GetOwnerOfObject(hvoObj);
int hvoText = cache.GetOwnerOfObject(hvoPara);
IStText text = new StText(cache, hvoText);
ScrSection section = new ScrSection(cache, text.OwnerHVO);
BCVRef verseRef = new BCVRef(section.VerseRefStart);
Dictionary<int, FootnoteHashEntry> dict;
// Don't bother on empty cache - it will be created when needed. Need to use HVO to get GUID so we
// don't create the book and potentially cause the refresh routine to be called.
Guid bookGuid = cache.GetGuidFromId(section.OwnerHVO);
if (!cache.TryGetHashtable<int, FootnoteHashEntry>(bookGuid, out dict) ||
dict.Count == 0)
{
return;
}
AddFootnoteRefsInText(text, dict, ref verseRef);
}
示例5: ConvertBaseAnnotationToReal
/// <summary>
///
/// </summary>
/// <param name="fdoCache"></param>
/// <param name="dummyAnnHvo"></param>
/// <returns></returns>
public static ICmBaseAnnotation ConvertBaseAnnotationToReal(FdoCache fdoCache, int dummyAnnHvo)
{
using (SuppressSubTasks supressActionHandler = new SuppressSubTasks(fdoCache, true))
{
Debug.Assert(fdoCache.IsDummyObject(dummyAnnHvo));
if (!fdoCache.IsDummyObject(dummyAnnHvo) ||
fdoCache.GetClassOfObject(dummyAnnHvo) != CmBaseAnnotation.kclsidCmBaseAnnotation)
{
return null; // indicate no change.
}
ISilDataAccess sda = fdoCache.MainCacheAccessor;
ICmBaseAnnotation cbaDummy = (ICmBaseAnnotation)CmObject.CreateFromDBObject(fdoCache, dummyAnnHvo, false);
ICmBaseAnnotation cbaReal = CreateRealAnnotation(fdoCache, cbaDummy.AnnotationTypeRAHvo, cbaDummy.InstanceOfRAHvo,
cbaDummy.BeginObjectRAHvo, cbaDummy.Flid, cbaDummy.BeginOffset, cbaDummy.EndOffset);
cbaReal.WritingSystemRAHvo = cbaDummy.WritingSystemRAHvo;
int hvoRealAnn = cbaReal.Hvo;
// transfer any default analysis (guess)
int ktagTwficDefault = StTxtPara.TwficDefaultFlid(fdoCache);
int hvoTwficAnalysisGuess = fdoCache.GetObjProperty(dummyAnnHvo, ktagTwficDefault);
if (hvoTwficAnalysisGuess != 0)
{
fdoCache.VwCacheDaAccessor.CacheObjProp(hvoRealAnn, ktagTwficDefault, hvoTwficAnalysisGuess);
}
int textSegType = CmAnnotationDefn.TextSegment(fdoCache).Hvo;
int twficType = CmAnnotationDefn.Twfic(fdoCache).Hvo;
if (cbaDummy.AnnotationTypeRAHvo == twficType)
StTxtPara.CacheReplaceTWFICAnnotation(fdoCache, dummyAnnHvo, hvoRealAnn);
else if (cbaDummy.AnnotationTypeRAHvo == textSegType)
StTxtPara.CacheReplaceTextSegmentAnnotation(fdoCache, dummyAnnHvo, hvoRealAnn);
else
Debug.Assert(true, "CacheReplace does not yet support annotation type " + cbaDummy.AnnotationTypeRAHvo);
// now clear it from the cache, since we're done with it.
if (fdoCache.ActionHandlerAccessor != null)
fdoCache.ActionHandlerAccessor.AddAction(new ClearInfoOnCommitUndoAction(fdoCache, dummyAnnHvo));
return cbaReal;
}
}
示例6: CreateObjectLabel
/// <summary>
/// a factory method for creating the correct type of object label, depending on the
/// class of the object
/// </summary>
static public ObjectLabel CreateObjectLabel(FdoCache cache, int hvo,
string displayNameProperty, string displayWs)
{
if (hvo == 0)
{
return new NullObjectLabel(cache);
}
else
{
//enhance: this is very expensive currently, it loads the entire object.
// does it? it's not obvious to the casual observer...
uint classId = (uint)cache.GetClassOfObject(hvo);
uint baseClassId = 0;
if (classId == CmPossibility.kClassId)
baseClassId = classId; // not exactly true, but simplifies logic below.
else
baseClassId = cache.MetaDataCacheAccessor.GetBaseClsId(classId);
if (CmPossibility.kClassId == baseClassId)
return new CmPossibilityLabel(cache, hvo, displayNameProperty, displayWs);
else if (MoInflClass.kClassId == classId)
return new MoInflClassLabel(cache, hvo, displayNameProperty, displayWs);
else
return new ObjectLabel(cache, hvo, displayNameProperty, displayWs);
}
}
示例7: GetParentOfClass
public static int GetParentOfClass(FdoCache m_cache, int hvo, int classIdOfParentToSearchFor)
{
//save the caller the need to see if this property was empty or not
if(hvo <1)
return -1;
int classId = m_cache.GetClassOfObject(hvo) ;
while((!m_cache.IsSameOrSubclassOf(classId,classIdOfParentToSearchFor))
&& (classId != FDO.LangProj.LangProject.kClassId))
{
hvo = m_cache.GetOwnerOfObject(hvo);
classId = m_cache.GetClassOfObject(hvo) ;
}
if((!m_cache.IsSameOrSubclassOf(classId,classIdOfParentToSearchFor)))
return -1;
else
return hvo;
}
示例8: GetVariantRef
/// <summary>
/// If hvoEntry is the id of a variant, try to find an entry it's a variant of that
/// has a sense. Return the corresponding ILexEntryRef for the first such entry.
/// If this is being called to establish a default monomorphemic guess, skip over
/// any bound root or bound stem entries that hvoEntry may be a variant of.
/// </summary>
public static ILexEntryRef GetVariantRef(FdoCache cache, int hvoEntry, bool fMonoMorphemic)
{
ISilDataAccess sda = cache.MainCacheAccessor;
int cRef = sda.get_VecSize(hvoEntry, (int)LexEntry.LexEntryTags.kflidEntryRefs);
for (int i = 0; i < cRef; ++i)
{
int hvoRef = sda.get_VecItem(hvoEntry,
(int)LexEntry.LexEntryTags.kflidEntryRefs, i);
int refType = sda.get_IntProp(hvoRef,
(int)LexEntryRef.LexEntryRefTags.kflidRefType);
if (refType == LexEntryRef.krtVariant)
{
int cEntries = sda.get_VecSize(hvoRef,
(int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes);
if (cEntries != 1)
continue;
int hvoComponent = sda.get_VecItem(hvoRef,
(int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes, 0);
int clid = cache.GetClassOfObject(hvoComponent);
if (fMonoMorphemic && IsEntryBound(cache, hvoComponent, clid))
continue;
if (clid == LexSense.kclsidLexSense ||
sda.get_VecSize(hvoComponent, (int)LexEntry.LexEntryTags.kflidSenses) > 0)
{
return LexEntryRef.CreateFromDBObject(cache, hvoRef);
}
else
{
// Should we check for a variant of a variant of a ...?
}
}
}
return null; // nothing useful we can do.
}
示例9: CreateFromDBObject
/// ------------------------------------------------------------------------------------
/// <summary>
/// This variant looks up the type, but never checks validity, and allows control of whether
/// to load into cache.
/// </summary>
/// <param name="fcCache"></param>
/// <param name="hvo"></param>
/// <param name="bLoadIntoCache"></param>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public static ICmObject CreateFromDBObject(FdoCache fcCache, int hvo, bool bLoadIntoCache)
{
return CreateFromDBObject(fcCache, hvo,
GetTypeFromFWClassID(fcCache, fcCache.GetClassOfObject(hvo)),
false, // don't validity check
bLoadIntoCache);
}
示例10: MakeUi
/// <summary>
/// In many cases we don't really need the FDO object, which can be relatively expensive
/// to create. This version saves the information, and creates it when needed.
/// </summary>
/// <param name="cache"></param>
/// <param name="hvo"></param>
/// <returns></returns>
public static CmObjectUi MakeUi(FdoCache cache, int hvo)
{
return MakeUi(cache, hvo, (uint)cache.GetClassOfObject(hvo));
}
示例11: IsValidObject
/// <summary>
/// Uses CmObject base class to determine validity, since
/// subclasses can override IsValidObject() to use different validation logic.
/// </summary>
/// <param name="cache"></param>
/// <param name="hvo"></param>
/// <returns></returns>
static public bool IsValidObject(FdoCache cache, int hvo)
{
if (hvo == 0)
return false;
int clsid = cache.GetClassOfObject(hvo);
if (clsid == 0)
return false;
ICmObject co = CmObject.CreateFromDBObject(cache, hvo, GetTypeFromFWClassID(cache, clsid), false, false);
return co.IsValidObject();
}
示例12: InsertObjectIntoVirtualBackref
static internal int InsertObjectIntoVirtualBackref(FdoCache cache, Mediator mediator, IVwVirtualHandler vh,
int hvoSlice, uint clidNewObj, uint clidOwner, uint flid)
{
if (vh != null)
{
int clidSlice = cache.GetClassOfObject(hvoSlice);
if (clidNewObj == LexEntry.kclsidLexEntry &&
clidSlice == LexEntry.kclsidLexEntry &&
clidOwner == LexDb.kclsidLexDb)
{
if (vh.FieldName == "VariantFormEntryBackRefs")
{
using (InsertVariantDlg dlg = new InsertVariantDlg())
{
ILexEntry entOld = LexEntry.CreateFromDBObject(cache, hvoSlice);
dlg.SetHelpTopic("khtpInsertVariantDlg");
dlg.SetDlgInfo(cache, mediator, entOld as IVariantComponentLexeme);
if (dlg.ShowDialog() == DialogResult.OK && dlg.NewlyCreatedVariantEntryRefResult)
{
int insertPos = cache.GetVectorSize(hvoSlice, (int)flid);
cache.PropChanged(hvoSlice, (int)flid, insertPos, 1, 0);
return insertPos;
}
// say we've handled this.
return -2;
}
}
}
}
return -1;
}
示例13: GetWfiAnalysisFromWficInstanceOf
private static int GetWfiAnalysisFromWficInstanceOf(FdoCache cache, int hvoInstanceOf, out int hvoWordform)
{
hvoWordform = 0;
int hvoWfiAnalysis = 0;
int classid = cache.GetClassOfObject(hvoInstanceOf);
switch (classid)
{
case WfiWordform.kclsidWfiWordform:
hvoWordform = hvoInstanceOf;
return 0; // need use or make a guess for analysis
case WfiAnalysis.kclsidWfiAnalysis:
hvoWfiAnalysis = hvoInstanceOf;
break;
case WfiGloss.kclsidWfiGloss:
hvoWfiAnalysis = cache.GetOwnerOfObject(hvoInstanceOf);
break;
default:
throw new ArgumentException("cba.InstanceOf(" + hvoInstanceOf + ") class(" +
classid + ") is not WfiWordform, WfiAnalysis, or WfiGloss.");
}
return hvoWfiAnalysis;
}
示例14: FullyAnalyzed
// Is hvoAnn, currently analyzed as hvoAnalysis, fully analyzed?
// This means:
// -- it isn't a default (property InterlinVc.m_vc.ktagTwficDefault isn't cached)
// -- It's a WfiGloss, with non-empty form.
// -- Owner is a WfiAnalysis with non-empty Category.
// -- Owner has at least one WfiMorphBundle.
// -- For each WfiMorphBundle, Form, Msa, and Sense are all filled in.
// Alternatively, if hvoAnalysis is zero, the annotation is punctuation, which we don't analyze further;
// so return true to indicate that it needs no further attention.
internal bool FullyAnalyzed(FdoCache fdoCache, WsListManager listman, int hvoAnn, int hvoAnalysis)
{
int ktagTwficDefault = StTxtPara.TwficDefaultFlid(fdoCache);
if (hvoAnalysis == 0)
return true; // punctuation, treat as fully analyzed.
ISilDataAccess sda = fdoCache.MainCacheAccessor;
// Check for default. If the analysis we're showing is a default it needs at least confirmation.
if (sda.get_IsPropInCache(hvoAnn, ktagTwficDefault, (int)CellarModuleDefns.kcptReferenceAtom, 0)
&& sda.get_ObjectProp(hvoAnn, ktagTwficDefault) != 0)
return false;
int analysisClass = fdoCache.GetClassOfObject(hvoAnalysis);
if (analysisClass != (int)WfiGloss.kclsidWfiGloss && analysisClass != (int)WfiAnalysis.kclsidWfiAnalysis)
return false; // Has to BE an analysis...unless pathologically everything is off? Too bad if so...
int hvoWfiAnalysis = fdoCache.GetOwnerOfObject(hvoAnalysis);
int hvoWordform;
if (analysisClass == (int)WfiAnalysis.kclsidWfiAnalysis)
{
hvoWordform = hvoWfiAnalysis;
hvoWfiAnalysis = hvoAnalysis;
}
else
{
hvoWordform = fdoCache.GetOwnerOfObject(hvoWfiAnalysis);
}
foreach (InterlinLineSpec spec in m_vc.LineChoices)
{
// see if the information required for this linespec is present.
switch (spec.Flid)
{
case InterlinLineChoices.kflidWord:
int ws = m_vc.GetRealWs(hvoWordform, spec);
if (sda.get_MultiStringAlt(hvoWordform, (int)WfiWordform.WfiWordformTags.kflidForm, ws).Length == 0)
return false;
break;
case InterlinLineChoices.kflidLexEntries:
if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph))
return false;
break;
case InterlinLineChoices.kflidMorphemes:
if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMorph))
return false;
break;
case InterlinLineChoices.kflidLexGloss:
if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidSense))
return false;
break;
case InterlinLineChoices.kflidLexPos:
if (!CheckPropSetForAllMorphs(sda, hvoWfiAnalysis, (int)WfiMorphBundle.WfiMorphBundleTags.kflidMsa))
return false;
break;
case InterlinLineChoices.kflidWordGloss:
// If it isn't a WfiGloss the user needs a chance to supply a word gloss.
if (analysisClass != WfiGloss.kclsidWfiGloss)
return false;
// If it is empty for the (possibly magic) ws specified here, it needs filling in.
int ws1 = m_vc.GetRealWs(hvoAnalysis, spec);
if (sda.get_MultiStringAlt(hvoAnalysis, (int)WfiGloss.WfiGlossTags.kflidForm, ws1).Length == 0)
return false;
break;
case InterlinLineChoices.kflidWordPos:
if (sda.get_ObjectProp(hvoWfiAnalysis, (int)WfiAnalysis.WfiAnalysisTags.kflidCategory) == 0)
return false;
break;
case InterlinLineChoices.kflidFreeTrans:
case InterlinLineChoices.kflidLitTrans:
case InterlinLineChoices.kflidNote:
default:
// unrecognized or non-word-level annotation, nothing required.
break;
}
}
return true; // If we can't find anything to complain about, it's fully analyzed.
}
示例15: GetReversalIndexEntryWritingSystem
/// <summary>
/// Get the writing system for the given ReversalIndexEntry.
/// </summary>
/// <param name="cache"></param>
/// <param name="hvoObj"></param>
/// <param name="wsDefault"></param>
/// <returns></returns>
public static int GetReversalIndexEntryWritingSystem(FdoCache cache, int hvoObj, int wsDefault)
{
if (cache != null && hvoObj != 0)
{
IReversalIndex ri = null;
int clid = cache.GetClassOfObject(hvoObj);
switch (clid)
{
case ReversalIndex.kclsidReversalIndex:
ri = ReversalIndex.CreateFromDBObject(cache, hvoObj);
break;
case ReversalIndexEntry.kclsidReversalIndexEntry:
int hvoReversalIndex = cache.GetOwnerOfObjectOfClass(hvoObj, ReversalIndex.kclsidReversalIndex);
if (hvoReversalIndex > 0)
ri = ReversalIndex.CreateFromDBObject(cache, hvoReversalIndex);
break;
case PartOfSpeech.kclsidPartOfSpeech:
// It may be nested, but we need the owner (index) of the list,
// no matter how high up.
int reversalIndexId = cache.GetOwnerOfObjectOfClass(hvoObj, ReversalIndex.kclsidReversalIndex);
if (reversalIndexId > 0)
ri = ReversalIndex.CreateFromDBObject(cache, reversalIndexId);
break;
case LexSense.kclsidLexSense:
// Pick a plausible default reversal index for the LexSense.
case LexDb.kclsidLexDb: // happens while initializing bulk edit combos
default: // since this doesn't actually depend on the hvo, it's not a bad general default.
List<int> rgriCurrent = cache.LangProject.LexDbOA.CurrentReversalIndices;
if (rgriCurrent.Count > 0)
{
ri = ReversalIndex.CreateFromDBObject(cache, (int)rgriCurrent[0]);
}
else
{
if (cache.LangProject.LexDbOA.ReversalIndexesOC.Count > 0)
{
int hvo = cache.LangProject.LexDbOA.ReversalIndexesOC.HvoArray[0];
ri = (IReversalIndex)CmObject.CreateFromDBObject(cache, hvo);
}
}
break;
}
if (ri != null)
return ri.WritingSystemRAHvo;
}
return wsDefault;
}