本文整理汇总了C#中ISilDataAccess.get_ObjectProp方法的典型用法代码示例。如果您正苦于以下问题:C# ISilDataAccess.get_ObjectProp方法的具体用法?C# ISilDataAccess.get_ObjectProp怎么用?C# ISilDataAccess.get_ObjectProp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISilDataAccess
的用法示例。
在下文中一共展示了ISilDataAccess.get_ObjectProp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryToSetLangProjectHvo
/// -----------------------------------------------------------------------------------
/// <summary>
/// Attempts to look up the ownership hierarchy to find the HVO of the language project
/// to set the m_hvoLangProject member variable.
/// </summary>
/// -----------------------------------------------------------------------------------
private void TryToSetLangProjectHvo(ISilDataAccess sda, int hvo)
{
int hvoOwner = sda.get_ObjectProp(hvo, (int)CmObjectFields.kflidCmObject_Owner);
while (hvoOwner != 0)
{
int clsid = sda.get_IntProp(hvoOwner, (int)CmObjectFields.kflidCmObject_Class);
if (clsid == LangProjectTags.kClassId)
{
m_hvoLangProject = hvoOwner;
return;
}
hvoOwner = sda.get_IntProp(hvoOwner, (int)CmObjectFields.kflidCmObject_Owner);
}
// Not particularly true in the new architecture, since the WSes are loaded first, so get HVO 1.
// m_hvoLangProject = 1; // true 99.999% of the time as of 11/24/2008
throw new ArgumentException("Probably an ownerless object", "hvo");
}
示例2: IsItemEligible
private bool IsItemEligible(ISilDataAccess sda, int hvo, Set<int> possiblePOS)
{
bool fEnable = false;
int hvoMsa = sda.get_ObjectProp(hvo, (int)LexSense.LexSenseTags.kflidMorphoSyntaxAnalysis);
if (hvoMsa != 0)
{
int clsid = m_cache.GetClassOfObject(hvoMsa);
if (clsid == MoStemMsa.kClassId)
{
int pos = sda.get_ObjectProp(hvoMsa, (int)MoStemMsa.MoStemMsaTags.kflidPartOfSpeech);
if (pos != 0 && possiblePOS.Contains(pos))
{
// Only show it as a change if it is different
int hvoFeature = sda.get_ObjectProp(hvoMsa, (int)MoStemMsa.MoStemMsaTags.kflidMsFeatures);
fEnable = hvoFeature != m_selectedHvo;
}
}
}
return fEnable;
}
示例3: CheckPropSetForAllMorphs
// Check that the specified WfiAnalysis includes at least one morpheme bundle, and that all morpheme
// bundles have the specified property set. Return true if all is well.
private static bool CheckPropSetForAllMorphs(ISilDataAccess sda, int hvoWfiAnalysis, int flid)
{
int cbundle = sda.get_VecSize(hvoWfiAnalysis, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles);
if (cbundle == 0)
return false;
for (int ibundle = 0; ibundle < cbundle; ibundle++)
{
int hvoBundle = sda.get_VecItem(hvoWfiAnalysis, (int)WfiAnalysis.WfiAnalysisTags.kflidMorphBundles, ibundle);
if (sda.get_ObjectProp(hvoBundle, flid) == 0)
return false;
}
return true;
}
示例4: Test
public bool Test(int hvo, ISilDataAccess sda, Set<int> validHvos)
{
return validHvos.Contains(sda.get_ObjectProp(hvo, m_flid));
}
示例5: SenseWithMsa
/// <summary>
/// Starting from hvoBase, which may be a LexEntry or LexSense, find the most desirable sense that has
/// the requested MSA. flidSense should be LexEntry.kflidSenses or LexSense.kflidSenses as
/// appropriate.
/// First tries all the top-level senses, if none matches, try children of each sense recursively.
/// Note: arguably, should try all level-two senses before trying level 3. But level-3 senses are
/// vanishingly rare; a level 3 sense with a different msa from its parent is so rare that it isn't
/// worth the effort to be more precise.
/// </summary>
/// <param name="sda"></param>
/// <param name="hvoBase"></param>
/// <param name="flidSenses"></param>
/// <param name="hvoMsa"></param>
/// <returns></returns>
int SenseWithMsa(ISilDataAccess sda, int hvoBase, int flidSenses, int hvoMsa)
{
int csense = sda.get_VecSize(hvoBase, flidSenses);
for (int i = 0; i < csense; i++)
{
int hvoSense = sda.get_VecItem(hvoBase, flidSenses, i);
int hvoThisMsa = sda.get_ObjectProp(hvoSense, (int)LexSense.LexSenseTags.kflidMorphoSyntaxAnalysis);
if (hvoThisMsa == hvoMsa)
return hvoSense;
}
for (int i = 0; i < csense; i++)
{
int hvoSense = sda.get_VecItem(hvoBase, flidSenses, i);
int hvoSubSense = SenseWithMsa(sda, hvoSense, (int)LexSense.LexSenseTags.kflidSenses, hvoMsa);
if (hvoSubSense != 0)
return hvoSubSense;
}
return 0; // no suitable sense found.
}
示例6: ApplyAnalysisToInstancesOfWordform
private void ApplyAnalysisToInstancesOfWordform(ISilDataAccess sda, int hvoNewAnalysis, int hvoOldWordform, int hvoNewWordform, bool fIsSentenceInitialCaseChange)
{
foreach (int hvoAnn in GetNextXfic())
{
if (hvoAnn == m_hvoAnnotation)
continue; // already processed.
int hvoInstance = sda.get_ObjectProp(hvoAnn,
(int)CmAnnotation.CmAnnotationTags.kflidInstanceOf);
if (hvoInstance == 0)
continue; // skip punctuation.
if (CheckOkToConfirm(fIsSentenceInitialCaseChange,
hvoOldWordform, hvoNewWordform, hvoAnn, hvoInstance))
{
int hvoAnnNew = CacheAnalysisForAnnotation(hvoAnn, hvoNewAnalysis, sda);
if (hvoAnnNew != 0)
SimulateReplaceAnnotation(hvoAnnNew);
}
}
}
示例7: CollectBrowseItems
/// ------------------------------------------------------------------------------------
/// <summary>
/// Main (recursive) part of CollectBrowseItems. Given that hvo is to be displayed using node,
/// figure what objects to put in the list.
/// </summary>
/// <param name="hvo">The hvo.</param>
/// <param name="node">The node.</param>
/// <param name="collector">The collector.</param>
/// <param name="mdc">The MDC.</param>
/// <param name="sda">The sda.</param>
/// <param name="layouts">The layouts.</param>
/// <param name="caller">The caller.</param>
/// <param name="hvos">The hvos.</param>
/// <param name="flids">The flids.</param>
/// ------------------------------------------------------------------------------------
static void CollectBrowseItems(int hvo, XmlNode node, ArrayList collector,
IFwMetaDataCache mdc, ISilDataAccess sda, LayoutCache layouts, XmlNode caller, int[] hvos, int[] flids)
{
switch(node.Name)
{
case "obj":
{
int clsid = sda.get_IntProp(hvo, CmObjectTags.kflidClass);
int flid = mdc.GetFieldId2(clsid, XmlUtils.GetManditoryAttributeValue(node, "field"), true);
int hvoDst = sda.get_ObjectProp(hvo, flid);
if (hvoDst == 0)
{
// We want a row, even though it's blank for this column.
collector.Add(new ManyOnePathSortItem(hvo, hvos, flids));
return;
}
// At this point we have to mimic the process that XmlVc uses to come up with the
// node that will be used to process the destination item.
XmlNode dstNode = GetNodeForRelatedObject(hvoDst, caller, node, layouts, sda);
if (dstNode == null)
{
// maybe an old-style "frag" element? Anyway, we can't do anything smart,
// so just insert the original object.
collector.Add(new ManyOnePathSortItem(hvo, hvos, flids));
return;
}
CollectBrowseItems(hvoDst, dstNode, collector, mdc, sda, layouts, null, AppendInt(hvos, hvo), AppendInt(flids, flid));
}
break;
case "seq":
{
// very like "obj" except for the loop. How could we capture this?
int clsid = sda.get_IntProp(hvo, CmObjectTags.kflidClass);
int flid = mdc.GetFieldId2(clsid, XmlUtils.GetManditoryAttributeValue(node, "field"), true);
int chvo = sda.get_VecSize(hvo, flid);
if (chvo == 0)
{
// We want a row, even though it's blank for this column.
collector.Add(new ManyOnePathSortItem(hvo, hvos, flids));
return;
}
for (int ihvo = 0; ihvo < chvo; ihvo++)
{
int hvoDst = sda.get_VecItem(hvo, flid, ihvo);
// At this point we have to mimic the process that XmlVc uses to come up with the
// node that will be used to process the destination item.
XmlNode dstNode = GetNodeForRelatedObject(hvoDst, caller, node, layouts, sda);
if (dstNode == null)
{
if (ihvo == 0)
{
// maybe an old-style "frag" element? Anyway, we can't do anything smart,
// so just insert the original object.
collector.Add(new ManyOnePathSortItem(hvo, hvos, flids));
return;
}
// if this happens and it's not the first object, we have a funny mixture of modes.
// As a fall-back, skip this object.
continue;
}
CollectBrowseItems(hvoDst, dstNode, collector, mdc, sda, layouts, null, AppendInt(hvos, hvo), AppendInt(flids, flid));
}
}
break;
case "span":
case "para":
case "div":
case "concpara":
case "innerpile":
case "column":
// Review JohnT: In XmlVc, "part" is the one thing that calls ProcessChildren with non-null caller.
// this should make some difference here, but I can't figure what yet, or come up with a test that fails.
case "part":
case "layout":
// These are grouping nodes. In general this terminates things. However, if there is only
// one thing embedded apart from comments and properties, we can proceed.
XmlNode mainChild = FindMainChild(node);
if (mainChild == null)
{
// no single non-trivial child, keep our current object
collector.Add(new ManyOnePathSortItem(hvo, hvos, flids));
return;
}
// Recurse with same object, but process the 'main child'.
CollectBrowseItems(hvo, mainChild, collector, mdc, sda, layouts, caller, hvos, flids);
//.........这里部分代码省略.........
示例8: GetOriginalListValue
/// <summary>
/// It's possible that hvoItem will be an owner of a ghost (ie. an absent source object for m_flidAtomicProp).
/// In that case, the cache should return 0.
/// </summary>
/// <param name="sda"></param>
/// <param name="hvoItem"></param>
/// <returns></returns>
private int GetOriginalListValue(ISilDataAccess sda, int hvoItem)
{
return sda.get_ObjectProp(hvoItem, m_flidAtomicProp);
}
示例9: GetHvoOfProject
/// <summary>
/// Get the Hvo of the LangProject by tracing up the ownership chain from a known
/// CmPossibility with a fixed guid that exists in all FieldWorks projects.
/// </summary>
private int GetHvoOfProject(ISilDataAccess sda)
{
// fixed guid of a possibility eventually owned by LangProject
Guid guid = new Guid("d7f713e4-e8cf-11d3-9764-00c04f186933"); // MoMorphType: bound root
int hvoPoss = GetIdFromGuid(sda, ref guid);
int flidOwner = sda.MetaDataCache.GetFieldId("CmObject", "Owner", false);
int hvoNewOwner = sda.get_ObjectProp(hvoPoss, flidOwner);
int hvoOwner = 0;
while (hvoNewOwner != 0)
{
hvoOwner = hvoNewOwner;
hvoNewOwner = sda.get_ObjectProp(hvoOwner, flidOwner);
}
return hvoOwner;
}
示例10: CacheObjPropUndoAction
/// <summary>
/// Make one AND make the change to the cache.
/// </summary>
/// <param name="sda"></param>
/// <param name="hvo"></param>
/// <param name="flid"></param>
/// <param name="newValue"></param>
public CacheObjPropUndoAction(ISilDataAccess sda, int hvo, int flid, int newValue)
{
m_sda = sda;
m_hvo = hvo;
m_flid = flid;
m_newValue = newValue;
m_oldValue = 0;
// Since this is used for fake props, if it isn't already cached, it doesn't have an old value.
if (sda.get_IsPropInCache(hvo, flid, (int)CellarModuleDefns.kcptReferenceAtom, 0))
m_oldValue = sda.get_ObjectProp(hvo, flid);
DoIt(m_newValue);
}
示例11: Setup
public void Setup()
{
// Create the following:
// - part and layout inventories
// - metadata cache
// - DataAccess cache
// - collection of columns to display.
// We want a MetaDataCache that knows about
// - LexEntry.Senses, Msas, CitationForm, Bibliography, Etymology
// - LexSense.SemanticDomains, SenseType, Status, gloss
// - CmPossibility Name, abbr
// - MoMorphSynAnalysis
// - MoStemMsa
// - MoDerivationalMsa
m_mdc = FwMetaDataCacheClass.Create();
string m_sTestPath = Path.Combine(DirectoryFinder.FwSourceDirectory,
@"Common\Controls\XmlViews\XmlViewsTests\SampleCm.xml");
m_mdc.InitXml(m_sTestPath, true);
// We want ISilDataAccess with:
// - LexEntry (1) with no senses and one MSA (2)
// - LexEntry (4) with one sense (5) and no MSA
// - LexEntry (6) with three senses (7, 8, 9) and two MSAs (10, 11)
// - sense(5) with no semantic domains
// - senses with one SD (7->30, 8->31)
// - sense with three SDs, one the same as the first (9->30, 31, 32)
// - MoStemMsa (2, 11)
// - MoDerivationalMsa (10)
m_cda = VwCacheDaClass.Create();
m_sda = m_cda as ISilDataAccess;
m_wsf = LgWritingSystemFactoryClass.Create();
m_sda.WritingSystemFactory = m_wsf;
SimpleDataParser parser = new SimpleDataParser(m_mdc, m_cda);
parser.Parse(Path.Combine(DirectoryFinder.FwSourceDirectory,
@"Common\Controls\XmlViews\XmlViewsTests\SampleData.xml"));
int wsEn = m_wsf.GetWsFromStr("en");
// These are mainly to check out the parser.
Assert.AreEqual(3, m_sda.get_ObjectProp(2, 23011), "part of speech of an MoStemMsa");
Assert.AreEqual(2, m_sda.get_VecItem(1, 2009, 0), "owned msa");
Assert.AreEqual("noun", m_sda.get_MultiStringAlt(3, 7003, wsEn).Text, "got ms property");
Assert.AreEqual(9, m_sda.get_VecItem(6, 2010, 2), "3rd sense");
Assert.AreEqual(31, m_sda.get_VecItem(9, 21016, 1), "2nd semantic domain");
// Columns includes
// - CitationForm (string inside span)
// - Bibliography (string not in span)
// - Sense glosses (string in para in seq, nested in column element)
// - Semantic domains (pair of strings in para in seq in seq, using layout refs)
// - MSAs (simplified, but polymorphic with one having <choice> and one <obj> to CmPossibility
XmlDocument docColumns = new XmlDocument();
docColumns.Load(Path.Combine(DirectoryFinder.FwSourceDirectory,
@"Common\Controls\XmlViews\XmlViewsTests\TestColumns.xml"));
m_columnList = docColumns.DocumentElement.ChildNodes;
// Parts just has what those columns need.
string partDirectory = Path.Combine(DirectoryFinder.FwSourceDirectory,
@"Common\Controls\XmlViews\XmlViewsTests");
Dictionary<string, string[]> keyAttrs = new Dictionary<string, string[]>();
keyAttrs["layout"] = new string[] {"class", "type", "name" };
keyAttrs["group"] = new string[] {"label"};
keyAttrs["part"] = new string[] {"ref"};
// Currently there are no specialized layout files that match.
m_layoutInventory = new Inventory(new string[] {partDirectory},
"*Layouts.xml", "/LayoutInventory/*", keyAttrs);
keyAttrs = new Dictionary<string, string[]>();
keyAttrs["part"] = new string[] {"id"};
m_partInventory = new Inventory(new string[] {partDirectory},
"TestParts.xml", "/PartInventory/bin/*", keyAttrs);
if (m_layouts != null)
m_layouts.Dispose();
m_layouts = new LayoutCache(m_mdc, m_layoutInventory, m_partInventory);
}
示例12: RecomputeVirtuals
/// <summary>
/// If object hvo has no cached value for the property flidVirtual, do nothing.
/// Otherwise, compute a new value for the property, and issue a PropChanged. (Currently only string type supported)
/// If it has owning properties of type clidVirtual, do the same for all their items.
/// </summary>
/// <param name="hvo"></param>
/// <param name="flidVirtual"></param>
/// <param name="mdc"></param>
/// <param name="sda"></param>
private void RecomputeVirtuals(int hvo, uint clidVirtual, int flidVirtual, int typeVirtual, IFwMetaDataCache mdc, ISilDataAccess sda,
IVwVirtualHandler vh)
{
if (Cache.GetClassOfObject(hvo) != clidVirtual)
return;
// Unless it's a computeEveryTime property, we don't need to worry if it's not already cached.
if (vh.ComputeEveryTime || sda.get_IsPropInCache(hvo, flidVirtual, typeVirtual, 0))
{
vh.Load(hvo, flidVirtual, 0, Cache.VwCacheDaAccessor);
switch (typeVirtual)
{
case (int)CellarModuleDefns.kcptString:
sda.PropChanged(null, (int)PropChangeType.kpctNotifyAll, hvo, flidVirtual, 0, 0, 0);
break;
default:
Debug.WriteLine("RecomputeVirtuals: unimplemented prop type");
break;
}
}
uint[] flids = DbOps.GetFieldsInClassOfType(mdc, (int)clidVirtual, FieldType.kgrfcptOwning);
foreach (uint flid in flids)
{
int type = mdc.GetFieldType(flid);
if (type == (int)CellarModuleDefns.kfcptOwningAtom)
{
RecomputeVirtuals(sda.get_ObjectProp(hvo, (int)flid), clidVirtual, flidVirtual, typeVirtual, mdc, sda, vh);
}
else
{
// must be owning sequence or collection; do them all.
int chvo = sda.get_VecSize(hvo, (int)flid);
for (int i = 0; i < chvo; i++)
RecomputeVirtuals(sda.get_VecItem(hvo, (int)flid, i), clidVirtual, flidVirtual, typeVirtual, mdc, sda, vh);
}
}
}
示例13: TrySelectAnnotation
private void TrySelectAnnotation(ISilDataAccess sda, InterlinDocChild pane, int annHvo)
{
// Try our best not to select an annotation we know won't work.
int annoType = sda.get_ObjectProp(annHvo, kflidAnnotationType);
int annInstanceOfRAHvo = sda.get_ObjectProp(annHvo, kflidInstanceOf);
if (annInstanceOfRAHvo == 0 || annoType != CmAnnotationDefn.Twfic(Cache).Hvo)
{
// if we didn't set annHvo by our marker or Clerk.CurrentObject,
// then we must have already tried the first word.
if (m_bookmark.IndexOfParagraph < 0 && Clerk.CurrentObject.Hvo == 0)
return;
// reset our marker and return to avoid trying to reuse an "orphan annotation"
// resulting from an Undo(). (cf. LT-2663).
m_bookmark.Reset();
return; // Can't select nothing, so return.
}
pane.SelectAnnotation(annHvo);
}
示例14: UpdateMorphEntryAction
public UpdateMorphEntryAction(SandboxBase sandbox, int hvoMorph)
{
m_oldVals = new int[m_tags.Length];
m_newVals = new int[m_tags.Length];
m_sandbox = sandbox;
m_sda = m_sandbox.Caches.DataAccess;
m_originalAnalysis = m_sandbox.Analysis;
m_hvoMorph = hvoMorph;
for (int i = 0; i < m_tags.Length; i++ )
m_oldVals[i] = m_sda.get_ObjectProp(m_hvoMorph, m_tags[i]);
}
示例15: StringsFor
//.........这里部分代码省略.........
case "span":
{
return AssembleChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
}
case "column":
// top-level node for whole column; concatenate children as for "para"
// if multipara is false, otherwise as for "div"
if (XmlUtils.GetOptionalBooleanAttributeValue(layout, "multipara", false))
return ChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
else
return AssembleChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
case "part":
{
string partref = XmlUtils.GetOptionalAttributeValue(layout, "ref");
if (partref == null)
return ChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce); // an actual part, made up of its pieces
XmlNode part = XmlVc.GetNodeForPart(hvo, partref, false, sda, layoutCache);
// This is the critical place where we introduce a caller. The 'layout' is really a 'part ref' which is the
// 'caller' for all embedded nodes in the called part.
return StringsFor(fdoCache, sda, part, hvo, layoutCache, layout, stringTbl, wsForce);
}
case "div":
case "innerpile":
{
// Concatenate keys for child nodes (as distinct strings)
return ChildKeys(fdoCache, sda, layout, hvo, layoutCache, caller, stringTbl, wsForce);
}
case "obj":
{
// Follow the property, get the object, look up the layout to use,
// invoke recursively.
int flid = GetFlid(sda, layout, hvo);
int hvoTarget = sda.get_ObjectProp(hvo, flid);
if (hvoTarget == 0)
break; // return empty key
string targetLayoutName = XmlUtils.GetOptionalAttributeValue(layout, "layout"); // uses 'default' if missing.
XmlNode layoutTarget = GetLayoutNodeForChild(sda, hvoTarget, flid, targetLayoutName, layout, layoutCache);
if (layoutTarget == null)
break;
return ChildKeys(fdoCache, sda, layoutTarget, hvoTarget, layoutCache, caller, stringTbl, wsForce);
}
case "seq":
{
// Follow the property. For each object, look up the layout to use,
// invoke recursively, concatenate
int flid = GetFlid(sda, layout, hvo);
int[] contents;
int ctarget = sda.get_VecSize(hvo, flid);
using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative<int>(ctarget))
{
int chvo;
sda.VecProp(hvo, flid, ctarget, out chvo, arrayPtr);
contents = MarshalEx.NativeToArray<int>(arrayPtr, chvo);
}
string[] result = null;
string targetLayoutName = XmlVc.GetLayoutName(layout, caller); // also allows for finding "param" attr in caller, if not null
int i = 0;
foreach (int hvoTarget in contents)
{
int prevResultLength = GetArrayLength(result);
XmlNode layoutTarget = GetLayoutNodeForChild(sda, hvoTarget, flid, targetLayoutName, layout, layoutCache);
if (layoutTarget == null)
continue; // should not happen, but best recovery we can make
result = Concatenate(result, ChildKeys(fdoCache, sda, layoutTarget, hvoTarget, layoutCache, caller, stringTbl, wsForce));