当前位置: 首页>>代码示例>>C#>>正文


C# Guid.ToShortString6方法代码示例

本文整理汇总了C#中System.Guid.ToShortString6方法的典型用法代码示例。如果您正苦于以下问题:C# Guid.ToShortString6方法的具体用法?C# Guid.ToShortString6怎么用?C# Guid.ToShortString6使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Guid的用法示例。


在下文中一共展示了Guid.ToShortString6方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RequirePeer

        /// <summary>
        /// Find or create peer via its UUID
        /// </summary>
        /// <param name="uuid">the identity of peer</param>
        /// <param name="endpoint">the endpoint to which we will connect the new peer</param>
        /// <returns>A peer (existing, or new one connected to endpoint)</returns>
        private ZyrePeer RequirePeer(Guid uuid, string endpoint)
        {
            Debug.Assert(!string.IsNullOrEmpty(endpoint));
            ZyrePeer peer;
            if (_peers.TryGetValue(uuid, out peer))
            {
                if (!_reportedKnownPeersTmp.Contains(peer))
                {
                    var callingMethod1 = MethodNameLevelAbove();
                    _loggerDelegate?.Invoke($"{nameof(ZyreNode)}.{nameof(RequirePeer)}() called by {callingMethod1} returning already-known peer={peer}");
                    _reportedKnownPeersTmp.Add(peer);
                }
                return peer;
            }

            // Purge any previous peer on same endpoint
            foreach (var existingPeer in _peers.Values)
            {
                PurgePeer(existingPeer, endpoint);
            }
            var callingMethod2 = MethodNameLevelAbove();
            _loggerDelegate?.Invoke($"{nameof(ZyreNode)}.{nameof(RequirePeer)}() called by {callingMethod2} creating new peer with uuidShort={uuid.ToShortString6()}");
            peer = ZyrePeer.NewPeer(_peers, uuid, _loggerDelegate);
            peer.Origin = _name;
            peer.Connect(_uuid, endpoint);

            // Handshake discovery by sending HELLO as first message
            var helloMessage = new ZreMsg
            {
                Id = ZreMsg.MessageId.Hello,
                Hello =
                {
                    Endpoint = _endpoint,
                    Groups = _ownGroups.Keys.ToList(),
                    Status = _status,
                    Name = _name,
                    Headers = _headers
                }
            };
            _loggerDelegate?.Invoke($"{nameof(ZyreNode)}.{nameof(RequirePeer)}() called by {callingMethod2} created new peer={peer}. Sending Hello message...");
            peer.Send(helloMessage);
            return peer;
        }
开发者ID:NetMQ,项目名称:Zyre,代码行数:49,代码来源:ZyreNode.cs

示例2: ZyreNode

        private ZyreNode(PairSocket outbox, Action<string> loggerDelegate = null)
        {
            _outbox = outbox;
            _loggerDelegate = loggerDelegate;

            _beaconPort = ZreDiscoveryPort;
            _interval = TimeSpan.Zero; // Use default
            _uuid = Guid.NewGuid();
            _peers = new Dictionary<Guid, ZyrePeer>();
            _peerGroups = new Dictionary<string, ZyreGroup>();
            _ownGroups = new Dictionary<string, ZyreGroup>();
            _headers = new Dictionary<string, string>();

            //  Default name for node is first 6 characters of UUID:
            //  the shorter string is more readable in logs
            _name = _uuid.ToShortString6();

            //  Use ZMQ_ROUTER_HANDOVER so that when a peer disconnects and
            //  then reconnects, the new client connection is treated as the
            //  canonical one, and any old trailing commands are discarded.
            //  This RouterHandover option is currently not supported in NetMQ Feb 16 2016
            
            _actor = NetMQActor.Create(RunActor);
        }
开发者ID:NetMQ,项目名称:Zyre,代码行数:24,代码来源:ZyreNode.cs


注:本文中的System.Guid.ToShortString6方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。