本文整理汇总了C#中XCore.List.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.AddRange方法的具体用法?C# List.AddRange怎么用?C# List.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.List
的用法示例。
在下文中一共展示了List.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMergeinfo
protected override DummyCmObject GetMergeinfo(WindowParams wp, List<DummyCmObject> mergeCandidates, out string guiControl, out string helpTopic)
{
wp.m_title = FdoUiStrings.ksMergeReversalEntry;
wp.m_label = FdoUiStrings.ksEntries;
var rie = (IReversalIndexEntry) Object;
var filteredHvos = new HashSet<int>(rie.AllOwnedObjects.Select(obj => obj.Hvo)) { rie.Hvo }; // exclude `rie` and all of its subentries
var wsIndex = m_cache.ServiceLocator.WritingSystemManager.GetWsFromStr(rie.ReversalIndex.WritingSystem);
mergeCandidates.AddRange(from rieInner in rie.ReversalIndex.AllEntries
where !filteredHvos.Contains(rieInner.Hvo)
select new DummyCmObject(rieInner.Hvo, rieInner.ShortName, wsIndex));
guiControl = "MergeReversalEntryList";
helpTopic = "khtpMergeReversalEntry";
return new DummyCmObject(m_hvo, rie.ShortName, wsIndex);
}
示例2: CollectSegmentForms
private List<int> CollectSegmentForms(int ichMinCurSeg, int ichLimCurSeg, ref int ichLimLast,
ref ITsString tssFirstWordOfNextSegment)
{
List<int> formsInSegment = new List<int>();
List<int> punctuationAnnotations = new List<int>();
int ichMin, ichLim;
m_wordMaker.CurrentCharOffset = ichMinCurSeg;
ITsString tssWord;
if (tssFirstWordOfNextSegment != null)
{
tssWord = tssFirstWordOfNextSegment;
// back up by this word.
ichLim = ichMinCurSeg;
ichMin = ichLim - tssWord.Length;
}
else
{
tssWord = m_wordMaker.NextWord(out ichMin, out ichLim);
}
int ctwfics = 0;
do
{
if (tssWord == null)
{
// we've run out of twfics. collect the last remaining punctuation annotations.
//Debug.Assert(m_tssPara.Length == ichLimCurSeg);
CreatePunctAnnotations(ichLimLast, ichLimCurSeg, punctuationAnnotations);
break;
}
if (ichLimLast != ichMin)
{
// we need to add punctuations to the current segment.
CreatePunctAnnotations(ichLimLast, Math.Min(ichMin, ichLimCurSeg), punctuationAnnotations);
formsInSegment.AddRange(punctuationAnnotations);
punctuationAnnotations.Clear();
if (ichMin >= ichLimCurSeg)
{
// we need to add this twfic to the next segment.
tssFirstWordOfNextSegment = tssWord;
ichLimLast = ichLimCurSeg;
break;
}
}
// Create (or reuse if possible) twfic annotations.
ITsString tssWordAnn;
formsInSegment.Add(CreateOrReuseAnnotation(tssWord, ichMin, ichLim, ctwfics, out tssWordAnn));
if (tssWordAnn != null && tssWord.Length < tssWordAnn.Length)
{
// this must be a phrase, so advance appropriately in the text.
ichLimLast = ichMin + tssWordAnn.Length;
m_wordMaker.CurrentCharOffset = ichLimLast;
}
else
{
// still stepping by the word boundary.
ichLimLast = ichLim;
}
ctwfics++;
tssWord = m_wordMaker.NextWord(out ichMin, out ichLim);
} while (true);
formsInSegment.AddRange(punctuationAnnotations);
return formsInSegment;
}
示例3: ProcessAnalysesAndLexEntries
private void ProcessAnalysesAndLexEntries(ProgressDialogWorkingOn progress, IWfiWordform wfOld, IWfiWordform wfNew)
{
wfOld.SpellingStatus = (int)SpellingStatusStates.incorrect;
//if (UpdateLexicalEntries)
//{
// foreach (IWfiAnalysis wa in wfOld.AnalysesOC)
// {
// if (wa.MorphBundlesOS.Count == 1)
// {
// }
// }
//}
if (!KeepAnalyses)
{
// Remove multi-morpheme anals in src wf.
List<IWfiAnalysis> goners = new List<IWfiAnalysis>();
foreach (IWfiAnalysis goner in wfOld.AnalysesOC)
{
if (goner.MorphBundlesOS.Count > 1)
{
goners.Add(goner);
}
}
foreach (IWfiAnalysis goner in goners)
{
IWfiWordform wf = goner.OwnerOfClass<IWfiWordform>();
wf.AnalysesOC.Remove(goner);
}
goners.Clear();
}
if (UpdateLexicalEntries)
{
// Change LE allo on single morpheme anals.
foreach (IWfiAnalysis update in wfOld.AnalysesOC)
{
if (update.MorphBundlesOS.Count != 1)
continue; // Skip any with zero or more than one.
IWfiMorphBundle mb = update.MorphBundlesOS[0];
ITsString tss = mb.Form.get_String(m_vernWs);
string srcForm = tss.Text;
if (srcForm != null)
{
// Change morph bundle form.
mb.Form.set_String(m_vernWs, NewSpelling);
}
IMoForm mf = mb.MorphRA;
if (mf != null)
{
mf.Form.set_String(m_vernWs, NewSpelling);
}
}
}
// Move remaining anals from src wf to new wf.
// This changes the owners of the remaining ones,
// since it is an owning property.
var analyses = new List<IWfiAnalysis>();
analyses.AddRange(wfOld.AnalysesOC);
foreach (var anal in analyses)
wfNew.AnalysesOC.Add(anal);
}
示例4: ComputeValue
protected override void ComputeValue(List<ICmObject> chosenObjs, int hvoItem, out List<ICmObject> oldVals,
out List<ICmObject> newVal)
{
if (!m_doingSuggest)
{
base.ComputeValue(chosenObjs, hvoItem, out oldVals, out newVal);
return;
}
oldVals = GetOldVals(hvoItem);
// ComputeValue() is used by FakeDoIt to put values in the suggestion cache,
// and by DoIt to get values from the cache (and thereby not repeat the search).
if (m_suggestionCache.TryGetValue(hvoItem, out newVal))
{
return; // This must be the DoIt pass; MakeSuggestions clears out the cache each time.
}
// resist the temptation to do "newVal = oldVals"
// if we change newVal we don't want oldVals to change
newVal = new List<ICmObject>();
newVal.AddRange(oldVals);
var curObject = m_cache.ServiceLocator.GetObject(hvoItem) as ILexSense;
if (curObject == null)
return;
var matches = m_semDomRepo.FindCachedDomainsThatMatchWordsInSense(m_searchCache, curObject);
foreach (var domain in matches)
{
if (!newVal.Contains(domain))
newVal.Add(domain);
}
m_suggestionCache[hvoItem] = newVal; // This must be the FakeDoIt pass; cache semantic domains.
}
示例5: AddItem
public override void AddItem(int hvoNew)
{
CheckDisposed();
List<int> lexemes = new List<int>();
ILexEntryRef ler = m_obj as ILexEntryRef;
if (m_flid == (int)LexEntryRef.LexEntryRefTags.kflidComponentLexemes)
lexemes.AddRange(ler.ComponentLexemesRS.HvoArray);
else if (m_flid == (int)LexEntryRef.LexEntryRefTags.kflidPrimaryLexemes)
lexemes.AddRange(ler.PrimaryLexemesRS.HvoArray);
// don't add a duplicate items.
if (!lexemes.Contains(hvoNew))
{
lexemes.Add(hvoNew);
SetItems(lexemes);
}
}
示例6: FindAllRootBoxes
/// <summary>
///
/// </summary>
/// <param name="control"></param>
/// <returns>List contain zero or more IVwRootbox objects.</returns>
private List<IVwRootBox> FindAllRootBoxes(Control control)
{
List<IVwRootBox> rootboxes = new List<IVwRootBox>();
if (control is IRootSite)
{
rootboxes.AddRange((control as IRootSite).AllRootBoxes());
}
foreach (Control c in control.Controls)
{
rootboxes.AddRange(FindAllRootBoxes(c));
}
return rootboxes;
}
示例7: AddSimpleItems
private static void AddSimpleItems(List<string> results, string remaining)
{
if (string.IsNullOrWhiteSpace(remaining))
return;
results.AddRange(remaining.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(x => !string.IsNullOrWhiteSpace(x)));
}
示例8: BuildLayoutTree
private List<LayoutTreeNode> BuildLayoutTree(XmlNode xnLayoutType)
{ // configure LayoutType via its child configure nodes
List<LayoutTreeNode> rgltn = new List<LayoutTreeNode>();
foreach (XmlNode config in xnLayoutType.ChildNodes)
{ // expects a configure element
if (config is XmlComment || config.Name != "configure")
continue;
var ltn = BuildMainLayout(config);
if (XmlUtils.GetOptionalBooleanAttributeValue(config, "hideConfig", false))
rgltn.AddRange(ltn.Nodes.Cast<LayoutTreeNode>());
else
rgltn.Add(ltn);
}
return rgltn;
}
示例9: AllRootBoxes
/// ------------------------------------------------------------------------------------
/// <summary>
/// A list of zero or more internal rootboxes.
/// </summary>
/// <returns></returns>
/// ------------------------------------------------------------------------------------
public virtual List<IVwRootBox> AllRootBoxes()
{
CheckDisposed();
List<IVwRootBox> rootboxes = new List<IVwRootBox>();
for (int i = 0; i < m_slaves.Count; i++)
{
if (m_slaves[i] is IRootSite)
{
IRootSite rs = (IRootSite)m_slaves[i];
rootboxes.AddRange(rs.AllRootBoxes());
}
}
return rootboxes;
}
示例10: GetMessageTargets
/// <summary>
/// return an array of all of the objects which should
/// 1) be queried when looking for someone to deliver a message to
/// 2) be potential recipients of a broadcast
/// </summary>
/// <returns></returns>
public IxCoreColleague[] GetMessageTargets()
{
CheckDisposed();
List<IxCoreColleague> colleagues = new List<IxCoreColleague>();
if (m_list != null && m_list is IxCoreColleague)
colleagues.AddRange((m_list as IxCoreColleague).GetMessageTargets());
colleagues.Add(this);
return colleagues.ToArray();
}
示例11: CreateComboAndTreeItems
private void CreateComboAndTreeItems(string sLayoutType)
{
var configureLayouts = XmlUtils.FindNode(m_configurationParameters, "configureLayouts");
var layoutTypes = new List<XmlNode>();
layoutTypes.AddRange(configureLayouts.ChildNodes.OfType<XmlNode>().Where(x => x.Name == "layoutType"));
Debug.Assert(layoutTypes.Count > 0);
var xnConfig = layoutTypes[0].SelectSingleNode("configure");
Debug.Assert(xnConfig != null);
var configClass = XmlUtils.GetManditoryAttributeValue(xnConfig, "class");
foreach (var xn in m_layouts.GetLayoutTypes())
{
var xnConfigure = xn.SelectSingleNode("configure");
if (XmlUtils.GetManditoryAttributeValue(xnConfigure, "class") == configClass)
layoutTypes.Add(xn);
}
foreach (var xnLayoutType in layoutTypes)
{
if (xnLayoutType is XmlComment || xnLayoutType.Name != "layoutType")
continue;
string sLabel = XmlUtils.GetAttributeValue(xnLayoutType, "label");
if (sLabel == "$wsName")
{
string sLayout = XmlUtils.GetAttributeValue(xnLayoutType, "layout");
Debug.Assert(sLayout.EndsWith("-$ws"));
bool fReversalIndex = true;
foreach (XmlNode config in xnLayoutType.ChildNodes)
{
if (config is XmlComment || config.Name != "configure")
continue;
string sClass = XmlUtils.GetAttributeValue(config, "class");
if (sClass != "ReversalIndexEntry")
{
fReversalIndex = false;
break;
}
}
if (!fReversalIndex)
continue;
foreach (IReversalIndex ri in m_cache.LangProject.LexDbOA.CurrentReversalIndices)
{
IWritingSystem ws = m_cache.ServiceLocator.WritingSystemManager.Get(ri.WritingSystem);
string sWsTag = ws.Id;
m_layouts.ExpandWsTaggedNodes(sWsTag); // just in case we have a new index.
// Create a copy of the layoutType node for the specific writing system.
XmlNode xnRealLayout = CreateWsSpecficLayoutType(xnLayoutType,
ws.DisplayLabel, sLayout.Replace("$ws", sWsTag), sWsTag);
List<LayoutTreeNode> rgltnStyle = BuildLayoutTree(xnRealLayout);
m_cbDictType.Items.Add(new LayoutTypeComboItem(xnRealLayout, rgltnStyle));
}
}
else
{
List<LayoutTreeNode> rgltnStyle = BuildLayoutTree(xnLayoutType);
m_cbDictType.Items.Add(new LayoutTypeComboItem(xnLayoutType, rgltnStyle));
}
}
int idx = -1;
for (int i = 0; i < m_cbDictType.Items.Count; ++i)
{
var item = m_cbDictType.Items[i] as LayoutTypeComboItem;
if (item != null && item.LayoutName == sLayoutType)
{
idx = i;
break;
}
}
if (idx < 0)
idx = 0;
m_cbDictType.SelectedIndex = idx;
}
示例12: CoreDoIt
/// <summary>
/// Core of the DoIt method, may be called with or without progress dialog.
/// </summary>
/// <param name="dlg"></param>
private void CoreDoIt(ProgressDialogWorkingOn dlg)
{
// While we do the changes which we can much more efficiently Undo/Redo in this action,
// we don't want the various changes we make generating masses of SqlUndoActions.
IActionHandler handler = m_cache.ActionHandlerAccessor;
m_cache.MainCacheAccessor.SetActionHandler(null);
m_hvoNewWf = WfiWordform.FindOrCreateWordform(m_cache, m_newSpelling, m_vernWs, true);
try
{
foreach (KeyValuePair<int, ParaChangeInfo> pair in m_changedParas)
{
UpdateOffsets(pair.Key, pair.Value);
// Review JohnT: should we do the PropChanged, or not?? If not, we should force
// a Refresh when the dialog closes.
if (!pair.Value.OldContents.Equals(pair.Value.NewContents))
pair.Value.SetString(m_cache, pair.Value.NewContents, true);
UpdateProgress(dlg);
}
UpdateInstanceOf(m_hvoNewWf, dlg);
}
finally
{
m_cache.MainCacheAccessor.SetActionHandler(handler);
}
if (dlg != null)
dlg.WorkingOnText = MEStrings.ksDealingAnalyses;
m_cache.BeginUndoTask(string.Format(MEStrings.ksUndoChangeSpelling, m_oldSpelling, m_newSpelling),
string.Format(MEStrings.ksRedoChangeSpelling, m_oldSpelling, m_newSpelling));
m_cache.ActionHandlerAccessor.AddAction(this);
UpdateProgress(dlg);
// The destination wordform really exists and should be marked correct.
IWfiWordform wf = WfiWordform.CreateFromDBObject(m_cache, m_hvoNewWf);
m_oldOccurrencesNewWf = wf.OccurrencesInTexts.ToArray();
m_fWasNewSpellingCorrect = wf.SpellingStatus == (int)SpellingStatusStates.correct;
wf.SpellingStatus = (int)SpellingStatusStates.correct;
EnchantHelper.SetSpellingStatus(m_newSpelling, m_vernWs,
m_cache.LanguageWritingSystemFactoryAccessor, true);
UpdateProgress(dlg);
m_hvoOldWf = WfiWordform.FindOrCreateWordform(m_cache, m_oldSpelling, m_vernWs, true);
IWfiWordform wfOld = WfiWordform.CreateFromDBObject(m_cache, m_hvoOldWf);
m_oldOccurrencesOldWf = wfOld.OccurrencesInTexts.ToArray();
m_fWasOldSpellingCorrect = wfOld.SpellingStatus == (int)SpellingStatusStates.correct;
UpdateProgress(dlg);
// Compute new occurrence lists, save and cache
Set<int> changes = new Set<int>();
foreach (ParaChangeInfo info in m_changedParas.Values)
changes.AddRange(info.Changes);
if (AllChanged)
{
m_newOccurrencesOldWf = new int[0]; // no remaining occurrences
}
else
{
// Only some changed, need to figure m_newOccurrences
List<int> newOccurrencesOldWf = new List<int>();
foreach (int hvo in m_oldOccurrencesOldWf)
if (!changes.Contains(hvo))
newOccurrencesOldWf.Add(hvo);
m_newOccurrencesOldWf = newOccurrencesOldWf.ToArray();
}
UpdateProgress(dlg);
List<int> newOccurrences = new List<int>(m_oldOccurrencesNewWf.Length + changes.Count);
newOccurrences.AddRange(m_oldOccurrencesNewWf);
foreach (int hvo in changes)
{
if (m_cache.IsDummyObject(hvo))
// if this is a dummy annotation, make sure we update the owner
m_cache.VwCacheDaAccessor.CacheObjProp(hvo, (int)CmObjectFields.kflidCmObject_Owner, m_hvoNewWf);
newOccurrences.Add(hvo);
}
m_newOccurrencesNewWf = newOccurrences.ToArray();
int vhId = BaseVirtualHandler.GetInstalledHandlerTag(m_cache, "WfiWordform", "OccurrencesInTexts");
m_cache.VwCacheDaAccessor.CacheVecProp(m_hvoOldWf, vhId, m_newOccurrencesOldWf, m_newOccurrencesOldWf.Length);
m_cache.VwCacheDaAccessor.CacheVecProp(m_hvoNewWf, vhId, m_newOccurrencesNewWf, m_newOccurrencesNewWf.Length);
SendCountVirtualPropChanged(m_hvoNewWf);
SendCountVirtualPropChanged(m_hvoOldWf);
UpdateProgress(dlg);
// Deal with analyses.
if (CopyAnalyses)
{
foreach (WfiAnalysis analysis in wfOld.AnalysesOC)
{
// Only copy approved analyses.
if (analysis.GetAgentOpinion(m_cache.LangProject.DefaultUserAgent) != Opinions.approves)
continue;
IWfiAnalysis newAnalysis = wf.AnalysesOC.Add(new WfiAnalysis());
foreach (WfiGloss gloss in analysis.MeaningsOC)
{
IWfiGloss newGloss = newAnalysis.MeaningsOC.Add(new WfiGloss());
newGloss.Form.CopyAlternatives(gloss.Form);
}
foreach (WfiMorphBundle bundle in analysis.MorphBundlesOS)
//.........这里部分代码省略.........
示例13: ConcordParagraphsOfTexts
internal static List<int> ConcordParagraphsOfTexts(FdoCache cache, int[] hvosStText, ProgressState progress,
IMatcher matcher, ConcordanceControl.ConcordanceLines line)
{
using (ParagraphParser pp = new ParagraphParser(cache))
{
// this will effectively clear ConcordanceWordforms, which seems overkill, but
// since we are changing the occurrences on those wordforms,
// and also possibly adding many new wordforms, we should just allow RecordLists that use
// ConcordanceWordforms to reload the list.
// (Enhance: is there any way we can make those lists be smart about when they need to reload,
// rather than forcing them to?)
(pp.m_wfi as WordformInventory).SuspendUpdatingConcordanceWordforms = true;
pp.CreateDummyWordforms = true;
pp.m_hvosStText = hvosStText;
if (matcher != null)
pp.m_matchingAnnotations = new List<int>();
ParagraphParser.ResetParseSessionDependentStaticData();
List<int> hvosParas = new List<int>();
ISilDataAccess sda = cache.MainCacheAccessor;
foreach (int hvo in hvosStText)
{
int chvoMax = sda.get_VecSize(hvo, (int)StText.StTextTags.kflidParagraphs);
using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative(chvoMax, typeof(int)))
{
int chvo;
sda.VecProp(hvo, (int)StText.StTextTags.kflidParagraphs, chvoMax, out chvo, arrayPtr);
Debug.Assert(chvo == chvoMax);
hvosParas.AddRange((int[])MarshalEx.NativeToArray(arrayPtr, chvo, typeof(int)));
}
}
int[] hvosStTxtPara = hvosParas.ToArray();
// Estimate the number of total number of milestones we'll set.
// Enhance: we could construct a way to set percentage done based upon
// number of texts and paragraphs in each text.
if (progress is MilestoneProgressState)
{
MilestoneProgressState mp = progress as SIL.FieldWorks.Common.Controls.MilestoneProgressState;
for (int i = 0; i < hvosStTxtPara.Length; ++i)
{
mp.AddMilestone(1);
}
}
// Preload all the paragraphs.
cache.PreloadIfMissing(hvosStTxtPara, (int)StTxtPara.StTxtParaTags.kflidContents, 0, false);
// Parse each text to load our paragraph and wordform segment annotations.
int cPara = 0;
using (SuppressSubTasks suppressor = new SuppressSubTasks(cache, true))
{
foreach (IStTxtPara para in new FdoObjectSet<IStTxtPara>(cache, hvosStTxtPara, false))
{
++cPara;
pp.Parse(para, matcher, line);
progress.SetMilestone();
progress.Breath();
if (pp.m_matchingAnnotations != null &&
pp.m_matchingAnnotations.Count >= ConcordanceControl.MaxConcordanceMatches())
{
MessageBox.Show(String.Format(ITextStrings.ksShowingOnlyTheFirstXXXMatches,
pp.m_matchingAnnotations.Count, cPara, hvosStTxtPara.Length),
ITextStrings.ksNotice, MessageBoxButtons.OK, MessageBoxIcon.Information);
break;
}
}
pp.CleanupLeftoverAnnotations(progress);
}
progress.SetMilestone();
progress.Breath();
(pp.m_wfi as WordformInventory).SuspendUpdatingConcordanceWordforms = false;
return pp.m_matchingAnnotations;
}
}
示例14: appendIntArray
private static int[] appendIntArray(int[] first, int[] second)
{
if (first.Length == 0)
return second;
if (second.Length == 0)
return first;
List<int> result = new List<int>(first);
result.AddRange(second);
return result.ToArray();
}
示例15: OnLoadSettings
/// ------------------------------------------------------------------------------------
/// <summary>
/// Save misc. view settings.
/// </summary>
/// ------------------------------------------------------------------------------------
protected override void OnLoadSettings(RegistryKey key)
{
base.OnLoadSettings(key);
if (m_availableChecksTree.Nodes.Count == 0)
return;
string value = key.GetValue("SelectedCheck", null) as string;
if (string.IsNullOrEmpty(value))
{
m_availableChecksTree.SelectedNode = m_availableChecksTree.Nodes[0];
return;
}
Guid checkId = new Guid(value);
// Get all the checked ScrChkTreeNodes
List<TreeNode> nodes = new List<TreeNode>(m_availableChecksTree.GetNodesOfTypeWithState(
typeof(ScrChkTreeNode), TriStateTreeView.CheckState.Checked));
// Add to it, all the unchecked ScrChkTreeNodes
nodes.AddRange(m_availableChecksTree.GetNodesOfTypeWithState(
typeof(ScrChkTreeNode), TriStateTreeView.CheckState.Unchecked));
// Find the node corresponding to the check id that was found in the registry.
foreach (TreeNode node in nodes)
{
if (((ScrChkTreeNode)node).ScrCheck.CheckId == checkId)
{
m_availableChecksTree.SelectedNode = node;
return;
}
}
}