本文整理汇总了C#中ImmutableHashSet.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableHashSet.Select方法的具体用法?C# ImmutableHashSet.Select怎么用?C# ImmutableHashSet.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableHashSet
的用法示例。
在下文中一共展示了ImmutableHashSet.Select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewRootWithAddedNamespaces
static async Task<SyntaxNode> GetNewRootWithAddedNamespaces(Document document, SyntaxNode relativeToNode,
CancellationToken cancellationToken, ImmutableHashSet<string> namespaceQualifiedStrings)
{
var namespaceWithUsings = relativeToNode
.GetAncestorsOrThis<NamespaceDeclarationSyntax>()
.FirstOrDefault(ns => ns.DescendantNodes().OfType<UsingDirectiveSyntax>().Any());
var root = await document.GetSyntaxRootAsync(cancellationToken);
SyntaxNode newRoot;
var usings = namespaceQualifiedStrings
.Select(ns => UsingDirective(ParseName(ns).WithAdditionalAnnotations(Simplifier.Annotation)));
if (namespaceWithUsings != null)
{
var newNamespaceDeclaration = namespaceWithUsings.WithUsings(namespaceWithUsings.Usings.AddRange(usings));
newRoot = root.ReplaceNode(namespaceWithUsings, newNamespaceDeclaration);
}
else
{
var compilationUnit = (CompilationUnitSyntax)root;
newRoot = compilationUnit.WithUsings(compilationUnit.Usings.AddRange(usings));
}
return newRoot;
}
示例2: GetPointsFromClearing
private Tuple<IEnumerable<Cell>, int> GetPointsFromClearing(ImmutableHashSet<Cell> allCells)
{
IEnumerable<Cell> newCells = allCells.ToList();
int addPoints = 0;
foreach (int row in allCells.Select(c => c.Y).Distinct().
Where(row => CheckRowFull(allCells, row)))
{
int rowNumber = row;
newCells = newCells.Where(c => c.Y != rowNumber).ToList();
var shiftCells = newCells.Where(r => r.Y < rowNumber).Select(c => new Cell(c.X, c.Y+1)).ToList();
newCells = newCells.Where(r => r.Y > rowNumber).Union(shiftCells);
addPoints++;
}
return new Tuple<IEnumerable<Cell>, int>(newCells, addPoints);
}
示例3: Active
private Receive Active(IActorRef receptionist)
{
return message =>
{
if (message is Send)
{
var send = (Send)message;
receptionist.Forward(new PublishSubscribe.Send(send.Path, send.Message, send.LocalAffinity));
}
else if (message is SendToAll)
{
var sendToAll = (SendToAll)message;
receptionist.Forward(new PublishSubscribe.SendToAll(sendToAll.Path, sendToAll.Message));
}
else if (message is Publish)
{
var publish = (Publish)message;
receptionist.Forward(new PublishSubscribe.Publish(publish.Topic, publish.Message));
}
else if (message is HeartbeatTick)
{
if (!_failureDetector.IsAvailable)
{
_log.Info("Lost contact with [{0}], restablishing connection", receptionist);
SendGetContacts();
ScheduleRefreshContactsTick(_settings.EstablishingGetContactsInterval);
Context.Become(Establishing);
_failureDetector.HeartBeat();
}
else
{
receptionist.Tell(ClusterReceptionist.Heartbeat.Instance);
}
}
else if (message is ClusterReceptionist.HeartbeatRsp)
{
_failureDetector.HeartBeat();
}
else if (message is RefreshContactsTick)
{
receptionist.Tell(ClusterReceptionist.GetContacts.Instance);
}
else if (message is ClusterReceptionist.Contacts)
{
var contacts = (ClusterReceptionist.Contacts)message;
// refresh of contacts
if (contacts.ContactPoints.Count > 0)
{
_contactPaths = contacts.ContactPoints.Select(ActorPath.Parse).ToImmutableHashSet();
_contacts = _contactPaths.Select(Context.ActorSelection).ToArray();
}
PublishContactPoints();
}
else if (message is ActorIdentity)
{
// ok, from previous establish, already handled
}
else
{
return ContactPointMessages(message);
}
return true;
};
}
示例4: Establishing
private bool Establishing(object message)
{
ICancelable connectTimerCancelable = null;
if (_settings.ReconnectTimeout.HasValue)
{
connectTimerCancelable = Context.System.Scheduler.ScheduleTellOnceCancelable(
_settings.ReconnectTimeout.Value,
Self,
ReconnectTimeout.Instance,
Self);
}
if (message is ClusterReceptionist.Contacts)
{
var contacts = (ClusterReceptionist.Contacts)message;
if (contacts.ContactPoints.Count > 0)
{
_contactPaths = contacts.ContactPoints.Select(ActorPath.Parse).ToImmutableHashSet();
_contacts = _contactPaths.Select(Context.ActorSelection).ToArray();
_contacts.ForEach(c => c.Tell(new Identify(null)));
}
PublishContactPoints();
}
else if (message is ActorIdentity)
{
var actorIdentify = (ActorIdentity)message;
var receptionist = actorIdentify.Subject;
if (receptionist != null)
{
_log.Info("Connected to [{0}]", receptionist.Path);
ScheduleRefreshContactsTick(_settings.RefreshContactsInterval);
SendBuffered(receptionist);
Context.Become(Active(receptionist));
connectTimerCancelable?.Cancel();
_failureDetector.HeartBeat();
}
else
{
// ok, use another instead
}
}
else if (message is HeartbeatTick)
{
_failureDetector.HeartBeat();
}
else if (message is RefreshContactsTick)
{
SendGetContacts();
}
else if (message is Send)
{
var send = (Send)message;
Buffer(new PublishSubscribe.Send(send.Path, send.Message, send.LocalAffinity));
}
else if (message is SendToAll)
{
var sendToAll = (SendToAll)message;
Buffer(new PublishSubscribe.SendToAll(sendToAll.Path, sendToAll.Message));
}
else if (message is Publish)
{
var publish = (Publish)message;
Buffer(new PublishSubscribe.Publish(publish.Topic, publish.Message));
}
else if (message is ReconnectTimeout)
{
_log.Warning("Receptionist reconnect not successful within {0} stopping cluster client", _settings.ReconnectTimeout);
Context.Stop(Self);
}
else
{
return ContactPointMessages(message);
}
return true;
}
示例5: ClusterClient
public ClusterClient(ClusterClientSettings settings)
{
if (settings.InitialContacts.Count == 0)
{
throw new ArgumentException("Initial contacts for cluster client cannot be empty");
}
_settings = settings;
_failureDetector = new DeadlineFailureDetector(_settings.AcceptableHeartbeatPause, _settings.HeartbeatInterval);
_contactPaths = settings.InitialContacts.ToImmutableHashSet();
_initialContactsSelections = _contactPaths.Select(Context.ActorSelection).ToArray();
_contacts = _initialContactsSelections;
SendGetContacts();
_contactPathsPublished = ImmutableHashSet<ActorPath>.Empty;
_subscribers = ImmutableList<IActorRef>.Empty;
_heartbeatTask = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable(
settings.HeartbeatInterval,
settings.HeartbeatInterval,
Self,
HeartbeatTick.Instance,
Self);
_refreshContactsCancelable = null;
ScheduleRefreshContactsTick(settings.EstablishingGetContactsInterval);
Self.Tell(RefreshContactsTick.Instance);
_buffer = new Queue<Tuple<object, IActorRef>>();
}
示例6: Joining
//State transition to JOINING - new node joining.
//Received `Join` message and replies with `Welcome` message, containing
// current gossip state, including the new joining member.
public void Joining(UniqueAddress node, ImmutableHashSet<string> roles)
{
if(node.Address.Protocol != _cluster.SelfAddress.Protocol)
{
_log.Warning("Member with wrong protocol tried to join, but was ignored, expected [{0}] but was [{1}]",
_cluster.SelfAddress.Protocol, node.Address.Protocol);
}
else if (node.Address.System != _cluster.SelfAddress.System)
{
_log.Warning(
"Member with wrong ActorSystem name tried to join, but was ignored, expected [{0}] but was [{1}]",
_cluster.SelfAddress.System, node.Address.System);
}
else
{
var localMembers = _latestGossip.Members;
// check by address without uid to make sure that node with same host:port is not allowed
// to join until previous node with that host:port has been removed from the cluster
var alreadyMember = localMembers.Any(m => m.Address == node.Address);
var isUnreachable = !_latestGossip.Overview.Reachability.IsReachable(node);
if (alreadyMember) _log.Info("Existing member [{0}] is trying to join, ignoring", node);
else if (isUnreachable) _log.Info("Unreachable member [{0}] is trying to join, ignoring", node);
else
{
// remove the node from the failure detector
_cluster.FailureDetector.Remove(node.Address);
// add joining node as Joining
// add self in case someone else joins before self has joined (Set discards duplicates)
var newMembers = localMembers
.Add(Member.Create(node, roles))
.Add(Member.Create(_cluster.SelfUniqueAddress, _cluster.SelfRoles));
var newGossip = _latestGossip.Copy(members: newMembers);
UpdateLatestGossip(newGossip);
_log.Info("Node [{0}] is JOINING, roles [{1}]", node.Address,
roles.Select(r => r.ToString()).Aggregate("", (a, b) => a + ", " + b));
if (!node.Equals(SelfUniqueAddress))
{
Sender.Tell(new InternalClusterAction.Welcome(SelfUniqueAddress, _latestGossip));
}
Publish(_latestGossip);
}
}
}