本文整理汇总了C#中HashSet.All方法的典型用法代码示例。如果您正苦于以下问题:C# HashSet.All方法的具体用法?C# HashSet.All怎么用?C# HashSet.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HashSet
的用法示例。
在下文中一共展示了HashSet.All方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FilterData
public void FilterData(ZusaarJson zusaarResult, ObservableCollection<AllEventsInfo> allEventsInfo, HashSet<string> ngWordsList, HashSet<string> cities)
{
if (zusaarResult != null)
{
var zusaaarInfo = from evnt in zusaarResult._event
where evnt.started_at <= DateTime.Now.AddMonths(5)
where evnt.started_at > DateTime.Now
join city in cities on SpecifyCity.GetCity(evnt.address) equals city
where ngWordsList.All(word => !evnt.title.Contains(word))
select new AllEventsInfo
{
Site = "site_zusaar.png",
Title = evnt.title,
Event_uri = evnt.event_url,
Start_at = evnt.started_at,
End_at = evnt.ended_at,
Description = evnt.description,
Overview = HtmlToString.GetString(evnt.description, 50),
Address = evnt.address,
City = SpecifyCity.GetCity(evnt.address),
Accepted = evnt.accepted,
Limit = evnt.limit,
Organizer = evnt.owner_nickname,
};
foreach (var item in zusaaarInfo)
{
allEventsInfo.Add(item);
}
}
}
示例2: ImportsFor
//Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
//{
// throw new NotImplementedException();
//}
private static string ImportsFor(HashSet<string> namespaces)
{
StringBuilder builder = new StringBuilder();
namespaces.All(s => { builder.AppendFormat("using {0};{1}", s, Environment.NewLine); return true; });
return builder.ToString();
}
示例3: FilterData
public void FilterData(List<DoorkeeperJson> doorkeeperResult, ObservableCollection<AllEventsInfo> allEventsInfo, HashSet<string> ngWordsList, HashSet<string> cities)
{
if (doorkeeperResult != null)
{
var doorkeeperInfo = from evnt in doorkeeperResult
join city in cities on SpecifyCity.GetCity(evnt._event.address) equals city
where evnt._event.starts_at <= DateTime.Now.AddMonths(5)
where evnt._event.starts_at > DateTime.Now
where ngWordsList.All(word => !evnt._event.title.Contains(word))
select new AllEventsInfo
{
Site = "site_doorkeeper.png",
Title = evnt._event.title,
Event_uri = evnt._event.public_url,
Start_at = evnt._event.starts_at,
End_at = evnt._event.ends_at,
Description = evnt._event.description,
Overview = HtmlToString.GetString(evnt._event.description, 50),
Address = evnt._event.address,
City = SpecifyCity.GetCity(evnt._event.address),
Accepted = evnt._event.participants,
Limit = evnt._event.ticket_limit,
Organizer = [email protected],
};
foreach (var item in doorkeeperInfo)
{
allEventsInfo.Add(item);
}
}
}
示例4: HashSetExtensions_All_ReturnsTrueIfHashSetIsEmpty
public void HashSetExtensions_All_ReturnsTrueIfHashSetIsEmpty()
{
var set = new HashSet<Int32>();
var result = set.All(x => x % 2 == 0);
TheResultingValue(result).ShouldBe(true);
}
示例5: HashSetExtensions_All_ReturnsTrueIfAllItemsMatchPredicate
public void HashSetExtensions_All_ReturnsTrueIfAllItemsMatchPredicate()
{
var set = new HashSet<Int32>() { 2, 4, 6 };
var result = set.All(x => x % 2 == 0);
TheResultingValue(result).ShouldBe(true);
}
示例6: HashSetExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate
public void HashSetExtensions_All_ReturnsFalseIfOneItemDoesNotMatchPredicate()
{
var set = new HashSet<Int32>() { 1, 2, 4, 6 };
var result = set.All(x => x % 2 == 0);
TheResultingValue(result).ShouldBe(false);
}
示例7: IsInGeneratedCodeDocument
public bool IsInGeneratedCodeDocument([NotNull] ISymbol symbol, CancellationToken cancellationToken)
{
Guard.NotNull(symbol, nameof(symbol));
// Return false when not all locations have generated comment; for example, partial classes.
IEnumerable<Location> locations = symbol.Locations.Where(location => location.IsInSource);
var trees = new HashSet<SyntaxTree>(locations.Select(location => location.SourceTree));
return trees.Any() && trees.All(tree => IsGeneratedCodeDocument(tree, cancellationToken));
}
示例8: TrimExcess
public void TrimExcess()
{
var set = new HashSet<int>();
foreach (int item in Enumerable.Range(100, 1000))
set.Add(item);
Assert.AreEqual(1000, set.Count);
set.TrimExcess();
Assert.AreEqual(1000, set.Count);
foreach (int item in Enumerable.Range(100, 1000))
Assert.IsTrue(set.Contains(item));
foreach (int item in Enumerable.Range(100, 1000).Where(i => i % 2 == 0))
set.Remove(item);
set.TrimExcess();
Assert.AreEqual(500, set.Count);
Assert.IsTrue(set.All(i => i % 2 == 1));
}
示例9: RemoteRouter_must_deploy_remote_routers_based_on_explicit_deployment
public void RemoteRouter_must_deploy_remote_routers_based_on_explicit_deployment()
{
var probe = CreateTestProbe(masterActorSystem);
var router = masterActorSystem.ActorOf(new RoundRobinPool(2).Props(Props.Create<Echo>())
.WithDeploy(
new Deploy(new RemoteScope(intendedRemoteAddress))), "remote-blub2");
router.Path.Address.ShouldBe(intendedRemoteAddress);
var replies = new HashSet<ActorPath>();
for (var i = 0; i < 5; i++)
{
router.Tell("", probe.Ref);
var expected = probe.ExpectMsg<IActorRef>(GetTimeoutOrDefault(null));
replies.Add(expected.Path);
}
Assert.Equal(2, replies.Count);
var parents = replies.Select(x => x.Parent).Distinct().ToList();
parents.Head().ShouldBe(router.Path);
Assert.True(replies.All(x => x.Address.Equals(intendedRemoteAddress)));
masterActorSystem.Stop(router);
}
示例10: RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_programmatic_definition
public void RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_programmatic_definition()
{
var probe = CreateTestProbe(masterActorSystem);
var router = masterActorSystem.ActorOf(new RemoteRouterConfig(new RoundRobinPool(2), new[] { new Address("akka.tcp", sysName, "localhost", port) })
.Props(Props.Create<Echo>()), "blub2");
var replies = new HashSet<ActorPath>();
for (var i = 0; i < 5; i++)
{
router.Tell("", probe.Ref);
var expected = probe.ExpectMsg<IActorRef>(GetTimeoutOrDefault(null));
replies.Add(expected.Path);
}
Assert.Equal(2, replies.Count);
Assert.Equal(1, replies.Select(x => x.Parent).Distinct().Count());
Assert.True(replies.All(x => x.Address.Equals(intendedRemoteAddress)));
masterActorSystem.Stop(router);
}
示例11: GetRootPackagesInDependencyOrder
private List<IPackage> GetRootPackagesInDependencyOrder()
{
var packagesInOrder = new List<IPackage>();
// Get all packages
var packages = new HashSet<IPackage>();
foreach (var package in LocalRepository.GetPackages().OrderBy(p => p.Id).ThenByDescending(p => p.Version))
{
if (packages.All(p => p.Id != package.Id))
{
packages.Add(package);
}
}
while (packages.Count > 0)
{
var nextPackage = packages.FirstOrDefault();
AddPackageRecursive(packagesInOrder, packages, nextPackage);
}
return packagesInOrder;
}
示例12: GetModulesInLib
/// <summary>
/// Returns a sequence of ModulePaths for all modules importable from
/// the specified library.
/// </summary>
public static IEnumerable<ModulePath> GetModulesInLib(
string interpreterPath,
string libraryPath,
string sitePath = null,
bool requireInitPyFiles = true
) {
if (File.Exists(interpreterPath)) {
interpreterPath = Path.GetDirectoryName(interpreterPath);
}
if (!Directory.Exists(libraryPath)) {
return Enumerable.Empty<ModulePath>();
}
if (string.IsNullOrEmpty(sitePath)) {
sitePath = Path.Combine(libraryPath, "site-packages");
}
var pthDirs = ExpandPathFiles(sitePath);
var excludedPthDirs = new HashSet<string>() {
sitePath,
libraryPath
};
// Get modules in stdlib
var modulesInStdLib = GetModulesInPath(libraryPath, true, true, requireInitPy: requireInitPyFiles);
// Get files in site-packages
var modulesInSitePackages = GetModulesInPath(sitePath, true, false, requireInitPy: requireInitPyFiles);
// Get directories in site-packages
// This is separate from getting files to ensure that each package
// gets its own library path.
var packagesInSitePackages = GetModulesInPath(sitePath, false, true, requireInitPy: requireInitPyFiles);
// Get modules in DLLs directory
IEnumerable<ModulePath> modulesInDllsPath;
// Get modules in interpreter directory
IEnumerable<ModulePath> modulesInExePath;
if (Directory.Exists(interpreterPath)) {
modulesInDllsPath = GetModulesInPath(Path.Combine(interpreterPath, "DLLs"), true, false);
modulesInExePath = GetModulesInPath(interpreterPath, true, false);
excludedPthDirs.Add(interpreterPath);
excludedPthDirs.Add(Path.Combine(interpreterPath, "DLLs"));
} else {
modulesInDllsPath = Enumerable.Empty<ModulePath>();
modulesInExePath = Enumerable.Empty<ModulePath>();
}
// Get directories referenced by pth files
var modulesInPath = GetModulesInPath(
pthDirs.Where(p1 => excludedPthDirs.All(p2 => !PathUtils.IsSameDirectory(p1, p2))),
true,
true,
requireInitPy: requireInitPyFiles
);
return modulesInPath
.Concat(modulesInDllsPath)
.Concat(modulesInStdLib)
.Concat(modulesInExePath)
.Concat(modulesInSitePackages)
.Concat(packagesInSitePackages);
}
示例13: RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_configuration
public void RemoteRouter_must_deploy_its_children_on_remote_host_driven_by_configuration()
{
var probe = CreateTestProbe(masterActorSystem);
var router = masterActorSystem.ActorOf(new RoundRobinPool(2).Props(Props.Create<Echo>()), "blub");
var replies = new HashSet<ActorPath>();
for (var i = 0; i < 5; i++)
{
router.Tell("", probe.Ref);
var expected = probe.ExpectMsg<ActorRef>();
replies.Add(expected.Path);
}
Assert.Equal(2, replies.Count);
Assert.Equal(1, replies.Select(x => x.Parent).Distinct().Count());
Assert.True(replies.All(x => x.Address.Equals(intendedRemoteAddress)));
masterActorSystem.Stop(router);
}
示例14: RemoteRouter_must_let_remote_deployment_router_be_overriden_by_local_configuration
public void RemoteRouter_must_let_remote_deployment_router_be_overriden_by_local_configuration()
{
var probe = CreateTestProbe(masterActorSystem);
var router = masterActorSystem.ActorOf(new RoundRobinPool(2).Props(Props.Create<Echo>())
.WithDeploy(
new Deploy(new RemoteScope(intendedRemoteAddress.Copy()))), "local-blub2");
// This line was subject to a bug in the original Akka - this router should be locally-deployed.
router.Path.Address.ToString().ShouldBe(string.Format("akka://{0}", masterActorSystem.Name));
var replies = new HashSet<ActorPath>();
for (var i = 0; i < 5; i++)
{
router.Tell("", probe.Ref);
var expected = probe.ExpectMsg<ActorRef>();
replies.Add(expected.Path);
}
Assert.Equal(4, replies.Count);
var parents = replies.Select(x => x.Parent).Distinct().ToList();
parents.Head().Address.ShouldBe(new Address("akka.tcp", sysName, "localhost", port));
Assert.True(replies.All(x => x.Address.Equals(intendedRemoteAddress)));
masterActorSystem.Stop(router);
}
示例15: RemoteRouter_must_deploy_remote_routers_based_on_configuration
public void RemoteRouter_must_deploy_remote_routers_based_on_configuration()
{
var probe = CreateTestProbe(masterActorSystem);
var router = masterActorSystem.ActorOf(Props.Create<Echo>().WithRouter(FromConfig.Instance), "remote-blub");
router.Path.Address.ShouldBe(intendedRemoteAddress);
var replies = new HashSet<ActorPath>();
for (var i = 0; i < 5; i++)
{
router.Tell("", probe.Ref);
var expected = probe.ExpectMsg<ActorRef>();
replies.Add(expected.Path);
}
Assert.Equal(2, replies.Count);
var parents = replies.Select(x => x.Parent).Distinct().ToList();
parents.Head().ShouldBe(router.Path);
Assert.True(replies.All(x => x.Address.Equals(intendedRemoteAddress)));
masterActorSystem.Stop(router);
}