本文整理汇总了C#中ImmutableList.Any方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableList.Any方法的具体用法?C# ImmutableList.Any怎么用?C# ImmutableList.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableList
的用法示例。
在下文中一共展示了ImmutableList.Any方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JoinSeedNodes
public void JoinSeedNodes(ImmutableList<Address> seedNodes)
{
if (seedNodes.Any())
{
StopSeedNodeProcess();
if (seedNodes.SequenceEqual(ImmutableList.Create(_cluster.SelfAddress)))
{
Self.Tell(new ClusterUserAction.JoinTo(_cluster.SelfAddress));
_seedNodeProcess = null;
}
else
{
// use unique name of this actor, stopSeedNodeProcess doesn't wait for termination
_seedNodeProcessCounter += 1;
if (seedNodes.Head().Equals(_cluster.SelfAddress))
{
_seedNodeProcess = Context.ActorOf(Props.Create(() => new FirstSeedNodeProcess(seedNodes)), "firstSeedNodeProcess-" + _seedNodeProcessCounter);
}
else
{
_seedNodeProcess = Context.ActorOf(Props.Create(() => new JoinSeedNodeProcess(seedNodes)).WithDispatcher(_cluster.Settings.UseDispatcher), "joinSeedNodeProcess-" + _seedNodeProcessCounter);
}
}
}
}
示例2: JoinSeedNodeProcess
public JoinSeedNodeProcess(ImmutableList<Address> seeds)
{
_selfAddress = Cluster.Get(Context.System).SelfAddress;
_seeds = seeds;
if (!seeds.Any() || seeds.Head() == _selfAddress)
throw new ArgumentException("Join seed node should not be done");
Context.SetReceiveTimeout(Cluster.Get(Context.System).Settings.SeedNodeTimeout);
}
示例3: OnReceive
protected override void OnReceive(object message)
{
if (message is InternalClusterAction.JoinSeenNode)
{
if (_timeout.HasTimeLeft)
{
// send InitJoin to remaining seed nodes (except myself)
foreach (
var seed in
_remainingSeeds.Select(
x => Context.ActorSelection(Context.Parent.Path.ToStringWithAddress(x))))
seed.Tell(new InternalClusterAction.InitJoin());
}
else
{
// no InitJoinAck received, initialize new cluster by joining myself
Context.Parent.Tell(new ClusterUserAction.JoinTo(_selfAddress));
Context.Stop(Self);
}
}
else if (message is InternalClusterAction.InitJoinAck)
{
// first InitJoinAck reply, join existing cluster
var initJoinAck = (InternalClusterAction.InitJoinAck)message;
Context.Parent.Tell(new ClusterUserAction.JoinTo(initJoinAck.Address));
Context.Stop(Self);
}
else if (message is InternalClusterAction.InitJoinNack)
{
var initJoinNack = (InternalClusterAction.InitJoinNack)message;
_remainingSeeds = _remainingSeeds.Remove(initJoinNack.Address);
if (!_remainingSeeds.Any())
{
// initialize new cluster by joining myself when nacks from all other seed nodes
Context.Parent.Tell(new ClusterUserAction.JoinTo(_selfAddress));
Context.Stop(Self);
}
}
else
{
Unhandled(message);
}
}
示例4: NavigatePageStack
private void NavigatePageStack(ImmutableList<Type> pageStack, ImmutableList<Type> priorPageStack)
{
var priorTop = priorPageStack?.LastOrDefault();
var priorSecond = priorPageStack != null && priorPageStack.Any()
? priorPageStack.Reverse().Skip(1).FirstOrDefault()
: null;
var currentTop = pageStack.LastOrDefault();
var currentSecond = pageStack.Any()
? pageStack.Reverse().Skip(1).FirstOrDefault()
: null;
if (currentTop == priorTop)
{
// All set.
}
else if (currentTop == priorSecond)
{
if (_rootFrame.CanGoBack)
_rootFrame.GoBack();
}
else if (currentSecond == priorTop)
{
_rootFrame.Navigate(currentTop);
}
if (_rootFrame.CurrentSourcePageType != currentTop)
{
while (_rootFrame.CanGoBack)
_rootFrame.GoBack();
if (currentTop != null)
_rootFrame.Navigate(currentTop);
}
}