Skip to content

Commit

Permalink
pre-deadlockfix
Browse files Browse the repository at this point in the history
  • Loading branch information
anderj017 committed Apr 13, 2015
1 parent eda3bc8 commit 67815ec
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Data/MoneyLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ public class MoneyLine

[XmlElement("homePrice")]
public double HomePrice { get; set; }

[XmlElement("drawPrice")]
public double DrawPrice { get; set; }
}
}
7 changes: 7 additions & 0 deletions Data/Period.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public class Period
[XmlElement("moneyLine")]
public MoneyLine MoneyLine { get; set; }

[XmlArray("totals")]
[XmlArrayItem("total")]
public List<TotalPoints> Totals { get; set; }

//[XmlElement("teamTotals")]
//public TeamTotalPoints TeamTotalPoints { get; set; } // temporarily unused

[XmlElement("maxBetAmount")]
public BetAmount MaxBetAmount { get; set; }
}
Expand Down
16 changes: 16 additions & 0 deletions Data/TeamTotalPoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Xml.Serialization;

namespace PinnacleWrapper.Data
{
[Serializable]
[XmlRoot("teamTotals")]
public class TeamTotalPoints
{
[XmlElement("homeTeamTotal")]
private TotalPoints HomeTeamTotal;

[XmlElement("awayTeamTotal")]
private TotalPoints AwayTeamTotal;
}
}
22 changes: 22 additions & 0 deletions Data/TotalPoints.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Xml.Serialization;

namespace PinnacleWrapper.Data
{
[Serializable]
[XmlRoot("teamTotal")]
public class TotalPoints
{
[XmlElement("@altLineId")]
public int? AltLineId;

[XmlElement("points")]
public decimal Points;

[XmlElement("overPrice")]
public decimal OverPrice;

[XmlElement("underPrice")]
public decimal UnderPrice;
}
}
14 changes: 10 additions & 4 deletions PinnacleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ protected T GetXmlAsync<T>(string requestType, params object[] values)
{
var response = _httpClient.GetAsync(string.Format(requestType, values)).Result;

var str = _httpClient.GetStringAsync(string.Format(requestType, values)).Result;

response.EnsureSuccessStatusCode(); // throw if web request failed

var xmlFormatter = new XmlMediaTypeFormatter { UseXmlSerializer = true };

var apiResponse = response.Content.ReadAsAsync<T>(new[] { xmlFormatter }).Result;

if (apiResponse.IsValid)
Expand Down Expand Up @@ -136,6 +139,11 @@ public Feed GetFeed(int sportId)
return GetFeed(sportId, new int[]{}, OddsFormat, CurrencyCode, -1, -1);
}

public Feed GetFeed(int sportId, long lastTimestamp)
{
return GetFeed(sportId, new int[] { }, OddsFormat, CurrencyCode, lastTimestamp);
}

public Feed GetFeed(int sportId, int[] leagueIds)
{
return GetFeed(sportId, leagueIds, OddsFormat, CurrencyCode, -1, -1);
Expand Down Expand Up @@ -174,12 +182,10 @@ protected async Task<T> GetJsonAsync<T>(string requestType, params object[] valu

response.EnsureSuccessStatusCode(); // throw if web request failed

var json = response.Content.ReadAsStringAsync().Result;
var json = await response.Content.ReadAsStringAsync();

// deserialise json async
var apiResponse = Task.Factory.StartNew(() => JsonConvert.DeserializeObject<T>(json));

return await apiResponse;
return JsonConvert.DeserializeObject<T>(json);
}

// ToDo: replace requestData object type with "IJsonSerialisable"
Expand Down
2 changes: 2 additions & 0 deletions PinnacleWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
<ItemGroup>
<Compile Include="Data\Bet.cs" />
<Compile Include="Data\BetAmount.cs" />
<Compile Include="Data\TeamTotalPoints.cs" />
<Compile Include="Data\TotalPoints.cs" />
<Compile Include="Enums\BetListType.cs" />
<Compile Include="Enums\BetStatus.cs" />
<Compile Include="Enums\BetType.cs" />
Expand Down

0 comments on commit 67815ec

Please sign in to comment.