Exemplo n.º 1
0
        public PlaceOrderOperation(RequestPlaceOrderMessage requestPlaceOrderMessage, IConnection connection, IOrdersStorageInternal ordersStorage, CancellationToken cancellationToken)
        {
            Contract.Requires(connection != null);
            Contract.Requires(ordersStorage != null);
            this.orderId = requestPlaceOrderMessage.OrderId;
            this.ordersStorage = ordersStorage;
            this.ordersStorage.OrderAdded += this.OnOrderAdded;

            cancellationToken.Register(() =>
            {
                this.Unsubscribe();
                this.taskCompletionSource.TrySetCanceled();
            });

            this.subscription = connection.SubscribeForErrors(error => error.RequestId == this.orderId, this.OnError);

            connection.SendMessage(requestPlaceOrderMessage);
        }
Exemplo n.º 2
0
 public Task<int> CreatePlaceOrderOperation(RequestPlaceOrderMessage requestPlaceOrderMessage,
     IOrdersStorageInternal ordersStorage,
     CancellationToken cancellationToken)
 {
     return
         new PlaceOrderOperation(requestPlaceOrderMessage, this.connection, ordersStorage, cancellationToken)
             .Result;
 }