本文整理汇总了C#中System.Collections.Set.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# Set.AddRange方法的具体用法?C# Set.AddRange怎么用?C# Set.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Set
的用法示例。
在下文中一共展示了Set.AddRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteObjectSideEffects
/// <summary>
/// This method is the one to override if you need side effects when DeleteUnderlyingObject
/// is called. If other objects should be deleted also, do NOT delete them directly; this
/// tends to produce abysmal performance. Rather, add them to objectsToDeleteAlso, and the
/// whole lot (including this) will be deleted in one relatively efficient operation.
/// You should not modify objectsToDeleteAlso except to add HVOs to it.
/// You must not use the FDO object after calling this, it has been put into the deleted state.
/// </summary>
/// <param name="objectsToDeleteAlso">hashtable of HVOs (value typically just true, it's really a set).</param>
/// <param name="state"></param>
public override void DeleteObjectSideEffects(Set<int> objectsToDeleteAlso, ProgressState state)
{
objectsToDeleteAlso.AddRange(FeatureConstraints);
base.DeleteObjectSideEffects(objectsToDeleteAlso, state);
}
示例2: ReferenceTargetCandidates
/// <summary>
/// Get a set of hvos that are suitable for targets to a reference property.
/// Subclasses should override this method to return a sensible list of IDs.
/// </summary>
/// <param name="flid">The reference property that can store the IDs.</param>
/// <returns>A set of hvos.</returns>
public override Set<int> ReferenceTargetCandidates(int flid)
{
Set<int> set = null;
switch (flid)
{
case (int)PhPhoneme.PhPhonemeTags.kflidFeatures:
set = new Set<int>();
set.AddRange(m_cache.LangProject.PhFeatureSystemOA.FeaturesOC.HvoArray);
break;
default:
set = base.ReferenceTargetCandidates(flid);
break;
}
return set;
}
示例3: VerifyCacheRules
/// <summary>
/// Confirm the set of cache rules in the given execution context includes a set of expected ones; assertion failure if not.
/// </summary>
/// <param name="ctx"></param>
/// <param name="rules"></param>
void VerifyCacheRules(ExecutionContext ctx, IList rules)
{
Set set = new Set();
foreach (CacheRule rule in ctx.CacheRules)
set.AddRange(rule.AllLeafRules);
foreach (CacheRule r in rules)
{
Assert.IsTrue(set.Contains(r), "Unable to find expected CacheRule (" + r.Description + ")");
set.Remove(r);
}
}
示例4: GetWritingSystems
/// <summary>
/// Return the possible writing systems that we might want to preload for the given fragment.
/// Note that currently this is for optimization and preloading; it is not (yet) guaranteed to
/// return EVERY writing system that might be displayed by the given fragment.
/// </summary>
/// <param name="frag"></param>
/// <param name="cache"></param>
/// <returns></returns>
public static Set<int> GetWritingSystems(XmlNode frag, FdoCache cache)
{
string wsSpec = null;
XmlAttribute xa = frag.Attributes["ws"];
if (xa == null)
return new Set<int>(0);
wsSpec = GetWsSpecWithoutPrefix(xa.Value);
Set<int> result = new Set<int>();
switch (wsSpec)
{
case "vernacular":
result.Add(cache.DefaultVernWs);
break;
case "analysis":
result.Add(cache.DefaultAnalWs);
break;
case "pronunciation":
case "all pronunciation":
result.Add(cache.LangProject.DefaultPronunciationWritingSystem);
break;
case "current":
break;
case "reversal":
// Enhance JohnT: make this (currently for optimization preloading) routine work
// better for reversal views
//actualWS = GetReversalIndexEntryWritingSystem(cache, hvoObj, wsDefault);
break;
case "best analorvern":
case "best vernoranal":
return cache.LangProject.CurrentAnalysisAndVernWss;
// Enhance JohnT: make this (currently for optimization preloading) routine work
// better for the above two cases: possibly add all current analysis and vernacular writing systems
case "analysis vernacular":
case "av":
case "vernacular analysis":
case "va":
result.Add(cache.DefaultVernWs);
result.Add(cache.DefaultAnalWs);
break;
case "user":
result.Add(cache.DefaultUserWs);
break;
case "best analysis":
case "all analysis":
result.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
break;
case "best vernacular":
case "all vernacular":
result.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
break;
default:
// See if we can get anywhere by treating it as an ICU locale.
// Note that it is important to do this in a way that won't create a new writing system for
// an invalid locale name, for example, if 'all analysis' is mistakenly passed to this routine.
// Note however that the behavior of recognizing an ICU locale name for an existing writing system
// definitely IS needed, e.g., when the user configures a Browse view to show an explicit writing system.
int wsT = cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(wsSpec);
if (wsT != 0)
result.Add(wsT);
break;
}
return result;
}
示例5: FindCorrespondingItemsInCurrentList
private Set<int> FindCorrespondingItemsInCurrentList(IDictionary<int, object> itemAndListSourceTokenPairs, PartOwnershipTree pot)
{
// create a reverse index of classes to a list of items
IDictionary<int, Set<int>> sourceFlidsToItems = MapSourceFlidsToItems(itemAndListSourceTokenPairs);
Set<int> relativesInCurrentList = new Set<int>();
foreach (KeyValuePair<int, Set<int>> sourceFlidToItems in sourceFlidsToItems)
{
Set<int> commonAncestors;
relativesInCurrentList.AddRange(pot.FindCorrespondingItemsInCurrentList(sourceFlidToItems.Key,
sourceFlidToItems.Value, m_flid,
out commonAncestors));
}
return relativesInCurrentList;
}
示例6: DisableItem
/// <summary>
/// kludge: filter to allow only complex entry references.
/// </summary>
/// <param name="hvoItem"></param>
/// <returns></returns>
protected override bool DisableItem(int hvoItem)
{
if (m_complexEntryRefs == null)
{
m_complexEntryRefs = new Set<int>();
Dictionary<int, List<int>> dict = new Dictionary<int,List<int>>();
LexEntry.LoadAllComplexFormEntryRefs(m_cache, dict);
// go through each list and add the values to our set.
foreach (List<int> refs in dict.Values)
m_complexEntryRefs.AddRange(refs);
}
return !m_complexEntryRefs.Contains(hvoItem);
}
示例7: ComputeEffects
/// <summary>
/// Given a Set of effects over abstract heap locations,
/// computes a set of effects over the method parameters
/// or in the global scope
/// </summary>
/// <param name="Effects"></param>
/// <returns></returns>
public Set<VariableEffect> ComputeEffects(AbstractEffects Effects)
{
Set<VariableEffect> variableEffects = new Set<VariableEffect>();
// Traverse every write effect
foreach (AField af in Effects)
variableEffects.AddRange(EffectsInVariables(af));
return variableEffects;
}
示例8: GetBestAlt
private int GetBestAlt(int hvo, int tag, int wsPreferred, int wsDefault, int[] wsList)
{
Set<int> wsSet = new Set<int>();
if (wsPreferred != 0)
wsSet.Add(wsPreferred);
wsSet.AddRange(wsList);
// We're not dealing with a real cache, so can't call something like this:
//ws = LangProject.InterpretWsLabel(m_caches.MainCache,
// LangProject.GetMagicWsNameFromId(ws),
// m_caches.MainCache.DefaultAnalWs,
// hvo, spec.StringFlid, null);
int wsActual = 0;
foreach (int ws1 in wsSet.ToArray())
{
ITsString tssTest = m_caches.DataAccess.get_MultiStringAlt(hvo, tag, ws1);
if (tssTest != null && tssTest.Length != 0)
{
wsActual = ws1;
break;
}
}
// Enhance JohnT: to be really picky here we should do like the real InterpretWsLabel
// and fall back to default UI language, then English.
// But we probably aren't even copying those alternatives to the sandbox cache.
if (wsActual == 0)
wsActual = wsDefault;
return wsActual;
}
示例9: ItemsToChange
internal Set<int> ItemsToChange(bool fOnlyIfSelected)
{
CheckDisposed();
Set<int> itemsToChange = new Set<int>();
if (fOnlyIfSelected)
{
itemsToChange.AddRange(m_bv.CheckedItems);
}
else
{
itemsToChange.AddRange(m_bv.AllItems);
}
return itemsToChange;
}
示例10: CheckboxBehavior_SiblingClassesItemsShouldInheritSelectionThroughParent_UnselectAll
public void CheckboxBehavior_SiblingClassesItemsShouldInheritSelectionThroughParent_UnselectAll()
{
// first create an entry with a pronunciation and some senses.
ILexPronunciation pronunciation;
ILexEntry parentEntry = CreateZZZparentEntryWithMultipleSensesAndPronunciation(out pronunciation);
// some entries (like variants) don't have senses, so we need to factor those into our results.
ICollection<ILexEntry> entriesWithoutSenses = FindEntriesWithoutSenses();
m_bulkEditBar.SwitchTab("BulkCopy");
m_bv.ShowColumn("Allomorph");
m_bulkEditBar.SetTargetField("Glosses");
RecordClerk clerk = (m_bv.Parent as RecordBrowseViewForTests).Clerk;
// Unselect All
m_bv.OnUncheckAll();
// now switch to allomorphs
using (FilterBehavior.Create(this))
m_bulkEditBar.SetTargetField("Allomorphs");
// validate that everything (except variant allomorph?) is still not selected.
Set<int> checkedItems = new Set<int>(m_bv.CheckedItems);
Set<int> selectedEntries = new Set<int>();
selectedEntries.AddRange(FdoVectorUtils.ConvertCmObjectsToHvos<ILexEntry>(entriesWithoutSenses));
Assert.AreEqual(selectedEntries.Count, checkedItems.Count);
}
示例11: CheckboxBehavior_ParentClassesItemsShouldInheritSelection_Selected
public void CheckboxBehavior_ParentClassesItemsShouldInheritSelection_Selected()
{
// find a lex entry that has multiple senses (i.e. descendents).
ILexEntry entryWithMultipleDescendents = CreateZZZparentEntryWithMultipleSensesAndPronunciation_AndUpdateList();
// some entries (like variants) don't have senses, so we need to factor those into our results.
ICollection<ILexEntry> entriesWithoutSenses = FindEntriesWithoutSenses();
m_bulkEditBar.SwitchTab("BulkCopy");
m_bulkEditBar.SetTargetField("Glosses");
Assert.AreEqual(LexSense.kclsidLexSense, m_bv.ListItemsClass);
RecordClerk clerk = (m_bv.Parent as RecordBrowseViewForTests).Clerk;
m_bv.OnUncheckAll();
// select the sense.
m_bv.SetCheckedItems(new int[] { entryWithMultipleDescendents.AllSenses[0].Hvo });
using (FilterBehavior.Create(this))
m_bulkEditBar.SetTargetField("Lexeme Form");
Set<int> selectedEntries = new Set<int>(new int[] {entryWithMultipleDescendents.Hvo});
selectedEntries.AddRange(FdoVectorUtils.ConvertCmObjectsToHvos<ILexEntry>(entriesWithoutSenses));
Set<int> checkedItems = new Set<int>(m_bv.CheckedItems);
Assert.AreEqual(selectedEntries.Count, checkedItems.Count, "Checked items mismatched.");
Assert.IsTrue(checkedItems.Equals(selectedEntries), "Checked items mismatched.");
}
示例12: RemoveUnwantedSortItems
/// <summary>
/// This will remove the given hvosToRemove (if they exist in our sort items) and any items that refer to invalid objects.
/// Reload the view if there were any changes, and adjust the CurrentIndex
/// </summary>
protected internal void RemoveUnwantedSortItems(List<int> hvosToRemove)
{
if (m_sortedObjects == null)
return; // nothing to remove.
bool fUpdatingListOrig = m_fUpdatingList;
m_fUpdatingList = true;
try
{
int currentIndex = CurrentIndex;
int cOrigSortObjects = m_sortedObjects.Count;
// Note: We start with a Set, since it can't have duplicates.
// First remove the given hvos from our sort items.
Set<int> unwantedIndices = new Set<int>(IndicesOfSortItems(hvosToRemove));
// then remove any remaining items that point to invalid objects.
unwantedIndices.AddRange(IndicesOfInvalidSortItems());
// Put the now unique indices into a list,
// so we can make sure they are processed in reverse order.
List<int> sortedIndices = new List<int>(unwantedIndices.ToArray());
sortedIndices.Sort();
sortedIndices.Reverse();
foreach (int indexOfSortItem in sortedIndices)
{
if (indexOfSortItem >= 0)
{
m_sortedObjects.RemoveAt(indexOfSortItem);
if (indexOfSortItem < currentIndex || SortedObjects.Count <= currentIndex)
currentIndex--;
}
}
if (m_sortedObjects.Count == 0)
currentIndex = -1;
else if (currentIndex >= m_sortedObjects.Count)
currentIndex = m_sortedObjects.Count - 1;
CurrentIndex = currentIndex;
if (m_sortedObjects.Count != cOrigSortObjects)
{
SendPropChangedOnListChange(CurrentIndex,
SortedObjects, ListChangedEventArgs.ListChangedActions.Normal);
}
}
finally
{
m_fUpdatingList = fUpdatingListOrig;
}
}
示例13: joinCalledMethod
private void joinCalledMethod(Dictionary<Label, Set<Method>> cm1, Dictionary<Label, Set<Method>> cm2)
{
foreach (Label lb in cm2.Keys)
{
Set<Method> mths2 = cm2[lb];
Set<Method> mths1 = new Set<Method>();
if (cm1.ContainsKey(lb))
{
mths1.AddRange(cm1[lb]);
}
mths1.AddRange(mths2);
cm1[lb] = mths1;
}
}
示例14: GetAllWritingSystems
/// <summary>
/// Get a Set of zero or more actual writing system IDs for the given ws identifier.
/// </summary>
/// <param name="sWs">One of our magic strings that signifies one or more writing systems</param>
/// <param name="cache"></param>
/// <param name="currentWS"></param>
/// <param name="hvo">object to use in determining 'best' names</param>
/// <param name="flid">flid to use in determining 'best' names</param>
/// <returns></returns>
public static Set<int> GetAllWritingSystems(string sWs, FdoCache cache, IWritingSystem currentWS, int hvo, int flid)
{
Set<int> allWsIds = new Set<int>();
if (sWs != null)
{
switch (sWs)
{
case "all analysis":
allWsIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
break;
case "all vernacular":
allWsIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
break;
case "analysis vernacular":
allWsIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
allWsIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
break;
case "vernacular analysis":
allWsIds.AddRange(cache.LangProject.CurVernWssRS.HvoArray);
allWsIds.AddRange(cache.LangProject.CurAnalysisWssRS.HvoArray);
break;
case "all pronunciation":
cache.LangProject.InitializePronunciationWritingSystems();
allWsIds.AddRange(cache.LangProject.CurPronunWssRS.HvoArray);
//if (allWsIds.Count == 0)
// allWsIds.Add(cache.LangProject.DefaultPronunciationWritingSystem);
break;
default:
sWs = GetWsSpecWithoutPrefix(sWs);
string[] rgsWs = sWs.Split(new char[] { ',' });
for (int i = 0; i < rgsWs.Length; ++i)
{
int ws = InterpretWsLabel(cache, rgsWs[i], 0, hvo, flid, currentWS);
if (ws != 0)
allWsIds.Add(ws);
}
break;
}
}
return allWsIds;
}
示例15: DeleteProject
/// ------------------------------------------------------------------------------------
/// <summary>
/// Lets the user delete any FW databases that are not currently open
/// </summary>
/// <param name="dialogOwner">The owner of the dialog</param>
/// <param name="helpTopicProvider">The help topic provider.</param>
/// ------------------------------------------------------------------------------------
internal static void DeleteProject(Form dialogOwner, IHelpTopicProvider helpTopicProvider)
{
Set<string> projectsInUse = new Set<string>(ProjectsInUseLocally());
IClientServerServices css = ClientServerServices.Current;
ILocalClientServerServices local = null;
if (css != null)
{
local = css.Local;
if (local != null && local.ShareMyProjects)
projectsInUse.AddRange(local.ListOpenProjects());
}
using (FwDeleteProjectDlg dlg = new FwDeleteProjectDlg(projectsInUse))
{
dlg.SetDialogProperties(helpTopicProvider);
dlg.ShowDialog(dialogOwner);
}
if (local != null)
local.RefreshProjectNames();
}