• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ConnectionId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ConnectionId的典型用法代码示例。如果您正苦于以下问题:C# ConnectionId类的具体用法?C# ConnectionId怎么用?C# ConnectionId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ConnectionId类属于命名空间,在下文中一共展示了ConnectionId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Equals_should_return_expected_result

        public void Equals_should_return_expected_result(
            int port1,
            int localValue1,
            int serverValue1,
            int port2,
            int localValue2,
            int serverValue2,
            bool expectedEqualsResult,
            bool expectedStructurallyEqualsResult)
        {
            var clusterId = new ClusterId();
            var serverId1 = new ServerId(clusterId, new DnsEndPoint("localhost", port1));
            var serverId2 = new ServerId(clusterId, new DnsEndPoint("localhost", port2));

            var subject1 = new ConnectionId(serverId1, localValue1).WithServerValue(serverValue1);
            var subject2 = new ConnectionId(serverId2, localValue2).WithServerValue(serverValue2);

            // note: Equals ignores the server values and StructurallyEquals compares all fields
            var equalsResult1 = subject1.Equals(subject2);
            var equalsResult2 = subject2.Equals(subject1);
            var structurallyEqualsResult1 = subject1.StructurallyEquals(subject2);
            var structurallyEqualsResult2 = subject2.StructurallyEquals(subject1);
            var hashCode1 = subject1.GetHashCode();
            var hashCode2 = subject2.GetHashCode();

            equalsResult1.Should().Be(expectedEqualsResult);
            equalsResult2.Should().Be(expectedEqualsResult);
            structurallyEqualsResult1.Should().Be(expectedStructurallyEqualsResult);
            structurallyEqualsResult2.Should().Be(expectedStructurallyEqualsResult);
            (hashCode1 == hashCode2).Should().Be(expectedEqualsResult);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:31,代码来源:ConnectionIdTests.cs


示例2: LocalValues_of_2_ids_should_not_be_the_same_when_automically_constructed

        public void LocalValues_of_2_ids_should_not_be_the_same_when_automically_constructed()
        {
            var subject = new ConnectionId(__serverId);
            var subject2 = new ConnectionId(__serverId);

            subject.LocalValue.Should().NotBe(subject2.LocalValue);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:7,代码来源:ConnectionIdTests.cs


示例3: ConnectionReceivingMessageFailedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionReceivingMessageFailedEvent" /> struct.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="responseTo">The id of the message we were receiving a response to.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="operationId">The operation identifier.</param>
 public ConnectionReceivingMessageFailedEvent(ConnectionId connectionId, int responseTo, Exception exception, long? operationId)
 {
     _connectionId = connectionId;
     _responseTo = responseTo;
     _exception = exception;
     _operationId = operationId;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:14,代码来源:ConnectionReceivingMessageFailedEvent.cs


示例4: ConnectionOpeningFailedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionOpeningFailedEvent" /> struct.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="operationId">The operation identifier.</param>
 public ConnectionOpeningFailedEvent(ConnectionId connectionId, ConnectionSettings connectionSettings, Exception exception, long? operationId)
 {
     _connectionId = connectionId;
     _connectionSettings = connectionSettings;
     _exception = exception;
     _operationId = operationId;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:14,代码来源:ConnectionOpeningFailedEvent.cs


示例5: ConnectionOpenedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionOpenedEvent" /> struct.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="connectionSettings">The connection settings.</param>
 /// <param name="duration">The duration of time it took to open the connection.</param>
 /// <param name="operationId">The operation identifier.</param>
 public ConnectionOpenedEvent(ConnectionId connectionId, ConnectionSettings connectionSettings, TimeSpan duration, long? operationId)
 {
     _connectionId = connectionId;
     _connectionSettings = connectionSettings;
     _duration = duration;
     _operationId = operationId;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:14,代码来源:ConnectionOpenedEvent.cs


示例6: Map

        /// <summary>
        /// Maps the specified response to a custom exception (if possible).
        /// </summary>
        /// <param name="connectionId">The connection identifier.</param>
        /// <param name="response">The response.</param>
        /// <returns>
        /// The custom exception (or null if the response could not be mapped to a custom exception).
        /// </returns>
        public static Exception Map(ConnectionId connectionId, BsonDocument response)
        {
            BsonValue code;
            if (response.TryGetValue("code", out code) && code.IsNumeric)
            {
                switch (code.ToInt32())
                {
                    case 50:
                    case 13475:
                    case 16986:
                    case 16712:
                        return new MongoExecutionTimeoutException(connectionId, message: "Operation exceeded time limit.");
                }
            }

            // the server sometimes sends a response that is missing the "code" field but does have an "errmsg" field
            BsonValue errmsg;
            if (response.TryGetValue("errmsg", out errmsg) && errmsg.IsString)
            {
                if (errmsg.AsString.Contains("exceeded time limit") ||
                    errmsg.AsString.Contains("execution terminated"))
                {
                    return new MongoExecutionTimeoutException(connectionId, message: "Operation exceeded time limit.");
                }
            }

            return null;
        }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:36,代码来源:ExceptionMapper.cs


示例7: ConnectionSendingMessagesFailedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionSendingMessagesFailedEvent" /> struct.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="requestIds">The request ids.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="operationId">The operation identifier.</param>
 public ConnectionSendingMessagesFailedEvent(ConnectionId connectionId, IReadOnlyList<int> requestIds, Exception exception, long? operationId)
 {
     _connectionId = connectionId;
     _requestIds = requestIds;
     _exception = exception;
     _operationId = operationId;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:14,代码来源:ConnectionSendingMessagesFailedEvent.cs


示例8: TestFixtureSetup

 public void TestFixtureSetup()
 {
     _connectionId = new ConnectionId(new ServerId(new ClusterId(1), new DnsEndPoint("localhost", 27017)), 2);
     _innerException = new Exception("inner");
     _writeConcernError = new WriteConcernError(1, "writeConcernError", new BsonDocument("details", "writeConcernError"));
     _writeError = new WriteError(ServerErrorCategory.Uncategorized, 1, "writeError", new BsonDocument("details", "writeError"));
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:7,代码来源:MongoWriteExceptionTests.cs


示例9: BinaryConnection

        // constructors
        public BinaryConnection(ServerId serverId, EndPoint endPoint, ConnectionSettings settings, IStreamFactory streamFactory, IConnectionInitializer connectionInitializer, IEventSubscriber eventSubscriber)
        {
            Ensure.IsNotNull(serverId, nameof(serverId));
            _endPoint = Ensure.IsNotNull(endPoint, nameof(endPoint));
            _settings = Ensure.IsNotNull(settings, nameof(settings));
            _streamFactory = Ensure.IsNotNull(streamFactory, nameof(streamFactory));
            _connectionInitializer = Ensure.IsNotNull(connectionInitializer, nameof(connectionInitializer));
            Ensure.IsNotNull(eventSubscriber, nameof(eventSubscriber));

            _backgroundTaskCancellationTokenSource = new CancellationTokenSource();
            _backgroundTaskCancellationToken = _backgroundTaskCancellationTokenSource.Token;

            _connectionId = new ConnectionId(serverId);
            _receiveCoordinator = new ReceiveCoordinator();
            _sendLock = new SemaphoreSlim(1);
            _state = new InterlockedInt32(State.Initial);

            _commandEventHelper = new CommandEventHelper(eventSubscriber);
            eventSubscriber.TryGetEventHandler(out _failedEventHandler);
            eventSubscriber.TryGetEventHandler(out _closingEventHandler);
            eventSubscriber.TryGetEventHandler(out _closedEventHandler);
            eventSubscriber.TryGetEventHandler(out _openingEventHandler);
            eventSubscriber.TryGetEventHandler(out _openedEventHandler);
            eventSubscriber.TryGetEventHandler(out _failedOpeningEventHandler);
            eventSubscriber.TryGetEventHandler(out _receivingMessageEventHandler);
            eventSubscriber.TryGetEventHandler(out _receivedMessageEventHandler);
            eventSubscriber.TryGetEventHandler(out _failedReceivingMessageEventHandler);
            eventSubscriber.TryGetEventHandler(out _sendingMessagesEventHandler);
            eventSubscriber.TryGetEventHandler(out _sentMessagesEventHandler);
            eventSubscriber.TryGetEventHandler(out _failedSendingMessagesEvent);
        }
开发者ID:huoxudong125,项目名称:mongo-csharp-driver,代码行数:32,代码来源:BinaryConnection.cs


示例10: ConnectionReceivedMessageEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionReceivedMessageEvent" /> struct.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="responseTo">The id of the message we received a response to.</param>
 /// <param name="length">The length of the received message.</param>
 /// <param name="networkDuration">The duration of network time it took to receive the message.</param>
 /// <param name="deserializationDuration">The duration of deserialization time it took to receive the message.</param>
 public ConnectionReceivedMessageEvent(ConnectionId connectionId, int responseTo, int length, TimeSpan networkDuration, TimeSpan deserializationDuration)
 {
     _connectionId = connectionId;
     _responseTo = responseTo;
     _length = length;
     _networkDuration = networkDuration;
     _deserializationDuration = deserializationDuration;
 }
开发者ID:kay-kim,项目名称:mongo-csharp-driver,代码行数:16,代码来源:ConnectionReceivedMessageEvent.cs


示例11: Format

 public static string Format(ConnectionId id)
 {
     if (id.ServerValue.HasValue)
     {
         return id.LocalValue.ToString() + "-" + id.ServerValue.Value.ToString();
     }
     return id.LocalValue.ToString();
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:8,代码来源:TraceSourceEventHelper.cs


示例12: ConnectionSentMessagesEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="ConnectionSentMessagesEvent" /> struct.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="requestIds">The request ids.</param>
 /// <param name="length">The length.</param>
 /// <param name="networkDuration">The duration of time spent on the network.</param>
 /// <param name="serializationDuration">The duration of time spent serializing the messages.</param>
 public ConnectionSentMessagesEvent(ConnectionId connectionId, IReadOnlyList<int> requestIds, int length, TimeSpan networkDuration, TimeSpan serializationDuration)
 {
     _connectionId = connectionId;
     _requestIds = requestIds;
     _length = length;
     _networkDuration = networkDuration;
     _serializationDuration = serializationDuration;
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:16,代码来源:ConnectionSentMessagesEvent.cs


示例13: FormatMessage

 // static methods
 private static string FormatMessage(ConnectionId connectionId, long cursorId)
 {
     return string.Format(
         "Cursor {0} not found on server {1} using connection {2}.",
         cursorId,
         EndPointHelper.ToString(connectionId.ServerId.EndPoint),
         connectionId.ServerValue);
 }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:9,代码来源:MongoCursorNotFoundException.cs


示例14: CommandFailedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="CommandFailedEvent" /> struct.
 /// </summary>
 /// <param name="commandName">Name of the command.</param>
 /// <param name="exception">The exception.</param>
 /// <param name="operationId">The operation identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="duration">The duration.</param>
 public CommandFailedEvent(string commandName, Exception exception, long? operationId, int requestId, ConnectionId connectionId, TimeSpan duration)
 {
     _commandName = Ensure.IsNotNullOrEmpty(commandName, "commandName");
     _exception = Ensure.IsNotNull(exception, "exception");
     _connectionId = Ensure.IsNotNull(connectionId, "connectionId");
     _operationId = operationId;
     _requestId = requestId;
     _duration = duration;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CommandFailedEvent.cs


示例15: CommandSucceededEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="CommandSucceededEvent"/> struct.
 /// </summary>
 /// <param name="commandName">Name of the command.</param>
 /// <param name="reply">The reply.</param>
 /// <param name="operationId">The operation identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="duration">The duration.</param>
 public CommandSucceededEvent(string commandName, BsonDocument reply, long? operationId, int requestId, ConnectionId connectionId, TimeSpan duration)
 {
     _commandName = Ensure.IsNotNullOrEmpty(commandName, "commandName");
     _reply = Ensure.IsNotNull(reply, "reply");
     _connectionId = Ensure.IsNotNull(connectionId, "connectionId");
     _operationId = operationId;
     _requestId = requestId;
     _duration = duration;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CommandSucceededEvent.cs


示例16: CommandStartedEvent

 /// <summary>
 /// Initializes a new instance of the <see cref="CommandStartedEvent" /> class.
 /// </summary>
 /// <param name="commandName">Name of the command.</param>
 /// <param name="command">The command.</param>
 /// <param name="databaseNamespace">The database namespace.</param>
 /// <param name="operationId">The operation identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="connectionId">The connection identifier.</param>
 public CommandStartedEvent(string commandName, BsonDocument command, DatabaseNamespace databaseNamespace, long? operationId, int requestId, ConnectionId connectionId)
 {
     _commandName = Ensure.IsNotNullOrEmpty(commandName, "commandName");
     _command = Ensure.IsNotNull(command, "command");
     _databaseNamespace = Ensure.IsNotNull(databaseNamespace, "databaseNamespace");
     _connectionId = Ensure.IsNotNull(connectionId, "connectionId");
     _operationId = operationId;
     _requestId = requestId;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:18,代码来源:CommandStartedEvent.cs


示例17: Equals

        public virtual bool Equals(ConnectionId that)
        {
            if(!Equals(this.Value, that.Value))
            {
                return false;
            }

            return true;
        }
开发者ID:ThorTech,项目名称:apache-nms,代码行数:9,代码来源:ConnectionId.cs


示例18: TcpConnection

 internal TcpConnection(ConnectionId connectionId, uint sequenceNumber, Action<TcpConnection>removeCallback, string snifferType)
 {
     ConnectionId = connectionId;
     Source = connectionId.Source;
     Destination = connectionId.Destination;
     InitialSequenceNumber = sequenceNumber;
     RemoveCallback = () => removeCallback(this);
     SnifferType = snifferType;
 }
开发者ID:neowutran,项目名称:ShinraMeter,代码行数:9,代码来源:TcpConnection.cs


示例19: Receive

        private void Receive(IpPacket ipPacket)
        {
            var protocol = ipPacket.Protocol;
            if (protocol != IPProtocolType.TCP)
            {
                return;
            }
            if (ipPacket.PayloadPacket == null)
            {
                return;
            }
            var tcpPacket = new TcpPacket(new ByteArraySegment(ipPacket.PayloadPacket.BytesHighPerformance));

            var isFirstPacket = tcpPacket.Syn;
            var sourceIp = new IPAddress(ipPacket.SourceAddress.GetAddressBytes()).ToString();
            var destinationIp = new IPAddress(ipPacket.DestinationAddress.GetAddressBytes()).ToString();
            var connectionId = new ConnectionId(sourceIp, tcpPacket.SourcePort, destinationIp, tcpPacket.DestinationPort);

            lock (_lock)
            {
                TcpConnection connection;
                bool isInterestingConnection;
                if (isFirstPacket)
                {
                    connection = new TcpConnection(connectionId, tcpPacket.SequenceNumber);
                    OnNewConnection(connection);
                    isInterestingConnection = connection.HasSubscribers;
                    if (!isInterestingConnection)
                    {
                        return;
                    }
                    _connections[connectionId] = connection;
                    Debug.Assert(ipPacket.PayloadPacket.PayloadData.Length == 0);
                }
                else
                {
                    isInterestingConnection = _connections.TryGetValue(connectionId, out connection);
                    if (!isInterestingConnection)
                    {
                        return;
                    }

                    if (!string.IsNullOrEmpty(TcpLogFile))
                    {
                        File.AppendAllText(TcpLogFile,
                            string.Format("{0} {1}+{4} | {2} {3}+{4} ACK {5} ({6})\r\n",
                                connection.CurrentSequenceNumber, tcpPacket.SequenceNumber, connection.BytesReceived,
                                connection.SequenceNumberToBytesReceived(tcpPacket.SequenceNumber),
                                ipPacket.PayloadLength, tcpPacket.AcknowledgmentNumber,
                                connection.BufferedPacketDescription));
                    }
                    connection.HandleTcpReceived(tcpPacket.SequenceNumber,
                        new ByteArraySegment(ipPacket.PayloadPacket.PayloadData));
                }
            }
        }
开发者ID:ha-tam,项目名称:TeraDamageMeter,代码行数:56,代码来源:TcpSniffer.cs


示例20: MongoWriteException

 /// <summary>
 /// Initializes a new instance of the <see cref="MongoWriteException" /> class.
 /// </summary>
 /// <param name="connectionId">The connection identifier.</param>
 /// <param name="writeError">The write error.</param>
 /// <param name="writeConcernError">The write concern error.</param>
 /// <param name="innerException">The inner exception.</param>
 public MongoWriteException(
     ConnectionId connectionId,
     WriteError writeError,
     WriteConcernError writeConcernError,
     Exception innerException)
     : base(connectionId, FormatMessage(writeError, writeConcernError), innerException)
 {
     _writeError = writeError;
     _writeConcernError = writeConcernError;
 }
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:17,代码来源:MongoWriteException.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ConnectionInfo类代码示例发布时间:2022-05-24
下一篇:
C# ConnectionFactory类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap