Beispiel #1
0
        /// <param name='operations'>
        /// The operations group for this extension method.
        /// </param>
        public static IList <Discount> Get(this IDiscountOperations operations,
                                           string locationId,
                                           bool isContinous = false)
        {
            //return new ActiveList<Discount>
            //{
            //    _Discounts = Task
            //    .Factory
            //    .StartNew(s => ((IDiscountOperations)s).GetAsync(locationId, beginTime, endTime, listOrder, limit), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)
            //    .Unwrap()
            //    .GetAwaiter()
            //    .GetResult(),
            //};

            var task = Task.Run(() => operations.GetWithHttpMessagesAsync(locationId, null));

            task.Wait();

            return(new ActiveList <Discount>
            {
                InitialUri = task.Result.Request.RequestUri.AbsoluteUri,
                Collection = task.Result.Body,
                NextUri = task.Result.ToNextUri(),
                Operations = operations,
                IsContinous = isContinous,
            });
        }
Beispiel #2
0
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <Discount> > GetAsync(this IDiscountOperations operations,
                                                       string locationId,
                                                       DateTime?beginTime                  = null,
                                                       DateTime?endTime                    = null,
                                                       ListOrderType?listOrder             = null,
                                                       short?limit                         = null,
                                                       bool isContinous                    = false,
                                                       CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var result = await operations.GetWithHttpMessagesAsync(locationId, null, cancellationToken).ConfigureAwait(false))
     {
         return(new ActiveList <Discount>
         {
             InitialUri = result.Request.RequestUri.AbsoluteUri,
             Collection = result.Body,
             NextUri = result.ToNextUri(),
             Operations = operations,
             IsContinous = isContinous,
             CancellationToken = cancellationToken,
         });
     }
 }