本文整理汇总了C#中ISilDataAccess.get_VecItem方法的典型用法代码示例。如果您正苦于以下问题:C# ISilDataAccess.get_VecItem方法的具体用法?C# ISilDataAccess.get_VecItem怎么用?C# ISilDataAccess.get_VecItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISilDataAccess
的用法示例。
在下文中一共展示了ISilDataAccess.get_VecItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddExcludedSenses
/// <summary>
/// Add to excludedSenses (an array of HVOs) any value in property flid of object
/// hvoBase (which might be entry or sense) which is not a member of includedSenses.
/// Also any nested senses.
/// </summary>
/// <param name="hvoBase"></param>
/// <param name="flid"></param>
/// <param name="excludedSenses"></param>
/// <param name="includedSenses"></param>
void AddExcludedSenses(ISilDataAccess sda, int hvoBase, int flid, List<int> excludedSenses, List<int> includedSenses)
{
int chvo = sda.get_VecSize(hvoBase, flid);
for (int ihvo = 0; ihvo < chvo; ihvo++)
{
int hvoSense = sda.get_VecItem(hvoBase, flid, ihvo);
if (!includedSenses.Contains(hvoSense))
excludedSenses.Add(hvoSense);
AddExcludedSenses(sda, hvoSense, (int)LexSense.LexSenseTags.kflidSenses, excludedSenses, includedSenses);
}
}
示例2: GetItems
/// ------------------------------------------------------------------------------------
/// <summary>
/// Get all the possibilities (or subpossibiities) of the owner and (optionally their
/// subpossibilities).
/// </summary>
/// <param name="hvoOwn">The hvo own.</param>
/// <param name="flid">flid for Possibilities for a CmPossibilityList, or
/// SubPossibilities for a CmPossibility</param>
/// <param name="list">list of ids to return.</param>
/// <param name="sda">The sda.</param>
/// <param name="fGetAllDescendants">if true, recurse to get ALL subpossibilities.</param>
/// ------------------------------------------------------------------------------------
private static void GetItems(int hvoOwn, int flid, Set<int> list, ISilDataAccess sda,
bool fGetAllDescendants)
{
int flidPss = (int)CellarModuleDefns.kflidCmPossibility_SubPossibilities;
int chvo = 0;
// Note, calling get_VecSize directly will result in a SQL query for all of the nodes of
// the tree to verify that they are zero. This generates around 1400 queries for the
// semantic domain list during loading. These will likely never be needed for anything
// else, so it simply wastes time.
if (sda.get_IsPropInCache(hvoOwn, flid, (int)FieldType.kcptOwningCollection, 0))
chvo = sda.get_VecSize(hvoOwn, flid);
for (int ihvo = 0; ihvo < chvo; ++ihvo)
{
int hvo = sda.get_VecItem(hvoOwn, flid, ihvo);
list.Add(hvo);
if (fGetAllDescendants)
CmPossibility.GetItems(hvo, flidPss, list, sda, fGetAllDescendants);
}
}
示例3: AddChildPos
/// <summary>
/// Add to possiblePOS all the children (recursively) of hvoPos
/// </summary>
/// <param name="sda"></param>
/// <param name="hvoPos"></param>
/// <param name="possiblePOS"></param>
void AddChildPos(ISilDataAccess sda, int hvoPos, Set<int> possiblePOS)
{
possiblePOS.Add(hvoPos);
int chvo = sda.get_VecSize(hvoPos, (int)CmPossibility.CmPossibilityTags.kflidSubPossibilities);
for (int i = 0; i < chvo; i++)
AddChildPos(sda, sda.get_VecItem(hvoPos,
(int)CmPossibility.CmPossibilityTags.kflidSubPossibilities, i), possiblePOS);
}
示例4: FindNestedObject
// Recursive helper method for IndexOf. Handles searching one property of one object (and
// its children) starting at a particular depth in the tree.
bool FindNestedObject(int hvoStart, int[] tags, int hvoTarget, int[] indexes, int[] hvos, int idepth,
ISilDataAccess sda)
{
int tag = tags[idepth];
int chvo = sda.get_VecSize(hvoStart, tag);
for (int i = 0; i < chvo; ++i)
{
int hvo = sda.get_VecItem(hvoStart, tag, i);
if (idepth == tags.Length - 1)
{
if (hvo == hvoTarget)
{
indexes[idepth] = i;
hvos[idepth] = hvoStart;
return true;
}
}
else
{
if (FindNestedObject(hvo, tags, hvoTarget, indexes, hvos, idepth + 1, sda))
{
indexes[idepth] = i;
hvos[idepth] = hvoStart;
return true;
}
}
}
return false;
}
示例5: 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;
}
示例6: CacheReplaceOneUndoAction
/// <summary>
/// Make one. Call DoIt to actually make the change.
/// </summary>
/// <param name="cache"></param>
/// <param name="hvo"></param>
/// <param name="flid"></param>
/// <param name="ihvoMin"></param>
/// <param name="ihvoLim"></param>
/// <param name="newValues"></param>
public CacheReplaceOneUndoAction(FdoCache cache, int hvo, int flid, int ihvoMin, int ihvoLim, int[] newValues)
{
m_cache = cache;
m_sda = cache.MainCacheAccessor;
m_hvo = hvo;
m_flid = flid;
IVwVirtualHandler vh;
if (m_cache.TryGetVirtualHandler(m_flid, out vh))
{
m_bvh = vh as BaseVirtualHandler;
}
m_index = ihvoMin;
m_newValues = newValues;
m_cvDel = ihvoLim - ihvoMin;
Debug.Assert(m_cvDel >= 0 && m_cvDel <= 1, "Currently only support deleting one item at a time.");
if (m_cvDel > 0)
m_oldValue = m_sda.get_VecItem(hvo, flid, ihvoMin);
}
示例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: GetNextSeg
/// <summary>
/// Given that idxCurSeg is the index of a segment of curPara, adjust both until it is the index of the
/// next segment (possibly in a later paragraph). Return false if no earlier segment exists in
/// the current text.
/// </summary
private static bool GetNextSeg(ref int idxCurSeg, ISilDataAccess sda,
ref StTxtPara curPara, int ktagParaSegments)
{
idxCurSeg++;
// This for usually exits early in the first iteration, and all we do in the method is increment idxCurSeg.
// It is even rarer to have more than one full iteration but could happen if there is an empty paragraph.
for (; ; )
{
int csegs = sda.get_VecSize(curPara.Hvo, ktagParaSegments);
if (idxCurSeg < csegs)
return true;
// set curPara to next para in StText. If there is none, fail.
int idxPara = sda.GetObjIndex(curPara.OwnerHVO, (int)StText.StTextTags.kflidParagraphs, curPara.Hvo);
int cpara = sda.get_VecSize(curPara.OwnerHVO, (int)StText.StTextTags.kflidParagraphs);
if (idxPara >= cpara - 1)
return false;
int hvoNext = sda.get_VecItem(curPara.OwnerHVO, (int)StText.StTextTags.kflidParagraphs, idxPara + 1);
curPara = CmObject.CreateFromDBObject(curPara.Cache, hvoNext, false) as StTxtPara;
idxCurSeg = 0;
}
}
示例9: 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);
}
示例10: GetPrevSeg
/// <summary>
/// Given that idxCurSeg is the index of a segment of curPara, adjust both until it is the index of the
/// previous segment (possibly in an earlier paragraph). Return false if no earlier segment exists in
/// the current text.
/// </summary
private static bool GetPrevSeg(ref int idxCurSeg, ISilDataAccess sda,
ref StTxtPara curPara, int ktagParaSegments)
{
idxCurSeg--;
// This while usually has no iterations, and all we do in the method is decrement idxCurSeg.
// It is even rarer to have more than one iteration but could happen if there is an empty paragraph.
while (idxCurSeg < 0)
{
// set curPara to previous para in StText. If there is none, fail.
int idxPara = sda.GetObjIndex(curPara.OwnerHVO, (int)StText.StTextTags.kflidParagraphs, curPara.Hvo);
if (idxPara == 0)
return false;
int hvoPrev = sda.get_VecItem(curPara.OwnerHVO, (int)StText.StTextTags.kflidParagraphs, idxPara - 1);
curPara = CmObject.CreateFromDBObject(curPara.Cache, hvoPrev, false) as StTxtPara;
idxCurSeg = sda.get_VecSize(curPara.Hvo, ktagParaSegments) - 1;
}
return true;
}
示例11: 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);
}
}
}
示例12: 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.
}
示例13: UpdateNotifierLists
/// <summary>
/// Update rghvo and rgtag to add each sense hvo with the Pictures flid.
/// </summary>
public override void UpdateNotifierLists(ISilDataAccess sda,
ref int[] rghvo, ref int[] rgtag, ref int chvo)
{
Debug.Assert(sda != null);
Debug.Assert(rghvo != null && rghvo.Length == 1);
Debug.Assert(rgtag != null && rgtag.Length == 1);
Debug.Assert(chvo == 1);
int hvoEntry = rghvo[0];
int csense = sda.get_VecSize(hvoEntry, (int)LexEntry.LexEntryTags.kflidSenses);
List<int> hvos = new List<int>();
List<int> tags = new List<int>();
// keep the existing entry hvo and (virtual) tag.
hvos.Add(hvoEntry);
tags.Add(rgtag[0]);
// also set dependency on the senses themselves.
hvos.Add(hvoEntry);
tags.Add((int)LexEntry.LexEntryTags.kflidSenses);
for (int isense = 0; isense < csense; isense++)
{
int hvoSense = sda.get_VecItem(hvoEntry, (int)LexEntry.LexEntryTags.kflidSenses, isense);
hvos.Add(hvoSense);
tags.Add((int)LexSense.LexSenseTags.kflidPictures);
}
rghvo = hvos.ToArray();
rgtag = tags.ToArray();
chvo = hvos.Count;
}
示例14: GetPictures
/// <summary>
/// Process the senses in property flidSub of object hvo, adding HVOs of any pictures
/// to the list.
/// </summary>
/// <param name="sda"></param>
/// <param name="hvo"></param>
/// <param name="flidSub"></param>
/// <param name="pictures"></param>
private void GetPictures(ISilDataAccess sda, int hvo, int flidSub, List<int> pictures)
{
int csense = sda.get_VecSize(hvo, flidSub);
for (int isense = 0; isense < csense; isense ++)
{
int hvoSense = sda.get_VecItem(hvo, flidSub, isense);
int cpic = sda.get_VecSize(hvoSense, (int)LexSense.LexSenseTags.kflidPictures);
for (int ipic = 0; ipic < cpic; ipic++)
{
pictures.Add(sda.get_VecItem(hvoSense, (int)LexSense.LexSenseTags.kflidPictures, ipic));
}
GetPictures(sda, hvoSense, (int)LexSense.LexSenseTags.kflidSenses, pictures);
}
}