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


C# ConnectionId类代码示例

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


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


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