本文整理汇总了C#中IList.Except方法的典型用法代码示例。如果您正苦于以下问题:C# IList.Except方法的具体用法?C# IList.Except怎么用?C# IList.Except使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IList
的用法示例。
在下文中一共展示了IList.Except方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddFiles
public void AddFiles(DroneConfig config, IList<string> sourceFiles, IList<string> referenceFiles)
{
if(config == null)
throw new ArgumentNullException("config");
if(sourceFiles == null)
throw new ArgumentNullException("sourceFiles");
if(referenceFiles == null)
throw new ArgumentNullException("referenceFiles");
var sourcesToAdd = sourceFiles.Except(config.SourceFiles).ToList();
var referencesToAdd = referenceFiles.Except(config.ReferenceFiles).ToList();
if (sourcesToAdd.Count == 0 && referencesToAdd.Count == 0)
{
this.log.Warn("no files added. files already exists in config");
return;
}
var fileNotFound = this.EnsureFilesExists(config.DirPath, sourcesToAdd.Concat(referencesToAdd));
if (fileNotFound)
return;
config.SourceFiles.AddRange(sourcesToAdd);
config.ReferenceFiles.AddRange(referencesToAdd);
foreach (var file in sourcesToAdd.Concat(referencesToAdd))
this.log.Info("added '{0}'", file);
}
示例2: Send
/// Assuming that excludeGroup is small
public void Send(Packet packet, IList<NetNode> sendToList, IList<NetNode> excludeGroup, int channel = 0)
{
var msg = packet.SendMessage(this);
var group = sendToList.Except(excludeGroup).Cast<NetConnection>().ToList();
if (group.Count == 0) return;
Peer.SendMessage(msg, group, (Lidgren.Network.NetDeliveryMethod)packet.Method, channel);
}
示例3: Analyze
public UserHistoryEntry Analyze(DateTime date, IList<long> before, IList<long> after)
{
var gainedIds = after.Except(before);
var lostIds = before.Except(after);
var allProfiles = parser.WhoAre(gainedIds.Concat(lostIds)).ToLookup(x => x.Id);
var gained = Separate(gainedIds, allProfiles);
var lost = Separate(lostIds, allProfiles);
return new UserHistoryEntry(date, gained, lost, after.Count);
}
示例4: UpdateProjects
public void UpdateProjects(IList<string> newProjects)
{
var oldProjects = Projects.Select(x => x.ProjectFilePath).ToList();
foreach (var i in newProjects.Except(oldProjects))
{
Projects.Add(new UploadProjectInfo(i));
}
foreach (var i in oldProjects.Except(newProjects))
{
Projects.RemoveAll(x => x.ProjectFilePath == i);
}
}
示例5: ChooseSets
public static List<int[]> ChooseSets(IList<int[]> sets, IList<int> universe)
{
var selectedSets = new List<int[]>();
while (universe.Count > 0)
{
var currentSet = sets.OrderByDescending(s => s.Count(universe.Contains)).First();
selectedSets.Add(currentSet);
sets.Remove(currentSet);
universe = universe.Except(currentSet).ToList();
}
return selectedSets;
}
示例6: SaveManga
public async Task SaveManga(IList<JsonManga> mangas)
{
if (mangas == null)
throw new ArgumentNullException("mangas");
_logger.Trace("Saving " + mangas.Count() + " mangas to database...");
using (MangaEdenContext context = new MangaEdenContext())
{
List<JsonManga> existing = await context.Mangas.ToListAsync();
context.Mangas.AddRange(mangas.Except(existing, new JsonMangaComparer()));
await context.SaveChangesAsync();
_logger.Trace("Saved.");
}
}
示例7: ProcessWatchers
public static IList<string> ProcessWatchers(this IBot bot, string repositoryName, IList<string> existingWatchers, IEnumerable<dynamic> watchers)
{
var currentWatchers = watchers.Select(c => c.login.ToString()).Cast<string>().ToList();
var newWatchers = currentWatchers.Except(existingWatchers).ToList();
foreach (var w in newWatchers)
{
bot.SayToAllRooms(string.Format("{0} is now watching {1}", w, repositoryName));
}
var noLongerWatching = existingWatchers.Except(currentWatchers).ToList();
foreach (var w in noLongerWatching)
{
bot.SayToAllRooms(string.Format("{0} is no longer watching {1}", w, repositoryName));
}
return existingWatchers.Concat(newWatchers).Except(noLongerWatching).ToList();
}
示例8: UpdateReferences
/// <summary>
/// Update the project file with the given references. Only change the file if
/// there would be an actual change tot he file required
/// </summary>
/// <param name="references"></param>
/// <returns>true if the project file was updated</returns>
internal bool UpdateReferences(IList<Reference> references)
{
var xmlDoc = ReadXML();
var existing = ReadReferences(xmlDoc).Where((r)=>r.HintPath != null).ToList();
var update = existing.Count != references.Count;
if (!update) {
update = existing.Except(references).ToList().Count > 0;
}
if (!update) {
update = references.Except(existing).ToList().Count > 0;
}
if (update) {
WriteReferences(xmlDoc,references);
return true;
}
return false;
}
示例9: SourceCreatorTreeNode
public SourceCreatorTreeNode(ISourceFactory factory, Type baseType, IList<Type> creatorTypes)
{
m_type = baseType;
if (!m_type.IsAbstract)
{
m_instance = Activator.CreateInstance(m_type, factory) as ISourceCreator;
m_instance.Init();
}
var childCreatorTypes = creatorTypes.Where(t => t.BaseType == m_type).ToList();
if (childCreatorTypes.Count > 0)
{
// remove children from search
creatorTypes = creatorTypes.Except(childCreatorTypes).ToList();
m_childCreatorNodes = childCreatorTypes.Select(t => new SourceCreatorTreeNode(factory, t, creatorTypes)).ToList();
}
}
示例10: UniquifyParameterNames
private static void UniquifyParameterNames(IList<FunctionParameter> parameters)
{
DebugCheck.NotNull(parameters);
foreach (var parameter in parameters)
{
parameter.Name = parameters.Except(new[] { parameter }).UniquifyName(parameter.Name);
}
}
示例11: SetPointerOver
private IInputElement SetPointerOver(IPointerDevice device, IInputRoot root, IList<IInputElement> elements)
{
foreach (var control in _pointerOvers.Except(elements).ToList())
{
PointerEventArgs e = new PointerEventArgs
{
RoutedEvent = InputElement.PointerLeaveEvent,
Device = device,
Source = control,
};
_pointerOvers.Remove(control);
control.RaiseEvent(e);
}
foreach (var control in elements.Except(_pointerOvers))
{
PointerEventArgs e = new PointerEventArgs
{
RoutedEvent = InputElement.PointerEnterEvent,
Device = device,
Source = control,
};
_pointerOvers.Add(control);
control.RaiseEvent(e);
}
root.PointerOverElement = elements.FirstOrDefault() ?? root;
return root.PointerOverElement;
}
示例12: GetDifference
private static IList<string> GetDifference(IList<string> existingHandles, IList<string> currentHandles)
{
// We are using LINQ to get the difference between the two lists.
// The non-LINQ version looks like the following:
// IList<string> differentHandles = new List<string>();
// foreach (string handle in currentHandles)
// {
// if (!existingHandles.Contains(handle))
// {
// currentHandles.Add(handle);
// }
// }
// return differentHandles;
return currentHandles.Except(existingHandles).ToList();
}
示例13: CompareListsNew
private static void CompareListsNew(IList<Article> list1, List<Article> list2, ListBox lb1, ListBox lb2, ListBox lb3)
{
lb1.BeginUpdate();
lb2.BeginUpdate();
lb3.BeginUpdate();
lb1.Items.AddRange(list1.Except(list2).ToArray());
lb2.Items.AddRange(list2.Except(list1).ToArray());
lb3.Items.AddRange(list1.Intersect(list2).ToArray());
lb1.EndUpdate();
lb2.EndUpdate();
lb3.EndUpdate();
}
示例14: AssertTypeRule
// ReSharper disable UnusedParameter.Local
private void AssertTypeRule(
Func<Type, IArgumentNullExceptionFixture> addMethod,
IList<RegexRule> existingRules,
IList<RegexRule> regexRules,
bool expectedInclude)
{
IArgumentNullExceptionFixture actual = addMethod(GetType());
Assert.Same(addMethod.Target, actual);
Assert.Equal(existingRules.Count + 1, regexRules.Count);
Assert.False(existingRules.Except(regexRules).Any());
RegexRule addedRule = regexRules.Except(existingRules).Single();
Assert.Equal(expectedInclude, addedRule.Include);
Assert.NotNull(addedRule.Type);
Assert.Null(addedRule.Method);
Assert.Null(addedRule.Parameter);
Assert.True(addedRule.MatchType(GetType()));
}
开发者ID:AutoTestNET,项目名称:AutoTest.ArgumentNullException,代码行数:19,代码来源:ArgumentNullExceptionFixtureExtensionsShould.cs
示例15: AllowTransitions
/// <summary>
/// allows only what is found in the return value of WhiteList
/// </summary>
public IEnumerable<ITransition> AllowTransitions(IList<ITransition> transitions)
{
return transitions.Except(base.TransitionsInCommonWithList(transitions))
.Where(x => object.Equals(x.WorkflowId, _workflowId));
}