示例#1
0
 /// <summary>
 /// Initializes client properties.
 /// </summary>
 private void Initialize()
 {
     this.LeaderboardEntryOperations = new LeaderboardEntryOperations(this);
     this.BaseUri          = new Uri("https://magicianschessdataapi.azurewebsites.net");
     SerializationSettings = new JsonSerializerSettings
     {
         Formatting            = Formatting.Indented,
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     DeserializationSettings = new JsonSerializerSettings
     {
         DateFormatHandling    = DateFormatHandling.IsoDateFormat,
         DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
         NullValueHandling     = NullValueHandling.Ignore,
         ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
         ContractResolver      = new ReadOnlyJsonContractResolver(),
         Converters            = new List <JsonConverter>
         {
             new Iso8601TimeSpanConverter()
         }
     };
     CustomInitialize();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <LeaderboardEntry> > GetAsync(this ILeaderboardEntryOperations operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='username'>
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <LeaderboardEntry> GetByIdAsync(this ILeaderboardEntryOperations operations, string username, int id, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetByIdWithHttpMessagesAsync(username, id, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='username'>
 /// </param>
 /// <param name='id'>
 /// </param>
 public static LeaderboardEntry GetById(this ILeaderboardEntryOperations operations, string username, int id)
 {
     return(Task.Factory.StartNew(s => ((ILeaderboardEntryOperations)s).GetByIdAsync(username, id), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='entry'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task PostAsync(this ILeaderboardEntryOperations operations, LeaderboardEntry entry, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.PostWithHttpMessagesAsync(entry, null, cancellationToken).ConfigureAwait(false);
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='entry'>
 /// </param>
 public static void Post(this ILeaderboardEntryOperations operations, LeaderboardEntry entry)
 {
     Task.Factory.StartNew(s => ((ILeaderboardEntryOperations)s).PostAsync(entry), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static IList <LeaderboardEntry> Get(this ILeaderboardEntryOperations operations)
 {
     return(Task.Factory.StartNew(s => ((ILeaderboardEntryOperations)s).GetAsync(), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='username'>
 /// </param>
 /// <param name='id'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task DeleteAsync(this ILeaderboardEntryOperations operations, string username, int id, CancellationToken cancellationToken = default(CancellationToken))
 {
     await operations.DeleteWithHttpMessagesAsync(username, id, null, cancellationToken).ConfigureAwait(false);
 }