コード例 #1
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="remoteAddress">TBD</param>
 /// <param name="statusPromise">TBD</param>
 /// <exception cref="FailureInjectorException">TBD</exception>
 protected override void InterceptAssociate(Address remoteAddress, TaskCompletionSource <AssociationHandle> statusPromise)
 {
     // Association is simulated to be failed if there was either an inbound or outbound message drop
     if (ShouldDropInbound(remoteAddress, new object(), "interceptAssociate") ||
         ShouldDropOutbound(remoteAddress, new object(), "interceptAssociate"))
     {
         statusPromise.SetException(
             new FailureInjectorException("Simulated failure of association to " + remoteAddress));
     }
     else
     {
         WrappedTransport.Associate(remoteAddress).ContinueWith(tr =>
         {
             var handle = tr.Result;
             addressChaosTable.AddOrUpdate(NakedAddress(handle.RemoteAddress), address => PassThru.Instance,
                                           (address, mode) => PassThru.Instance);
             statusPromise.SetResult(new FailureInjectorHandle(handle, this));
         }, TaskContinuationOptions.ExecuteSynchronously);
     }
 }