Skip to content

Commit 851603b

Browse files
committed
Quick fix for trollbox message parsing
1 parent 189489c commit 851603b

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

Diff for: PoloniexApi.Net/General/CurrencyPair.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
{
33
public class CurrencyPair
44
{
5+
private const char SeparatorCharacter = '_';
6+
57
public string BaseCurrency { get; private set; }
68
public string QuoteCurrency { get; private set; }
79

@@ -11,9 +13,15 @@ public CurrencyPair(string baseCurrency, string quoteCurrency)
1113
QuoteCurrency = quoteCurrency;
1214
}
1315

16+
public static CurrencyPair Parse(string currencyPair)
17+
{
18+
var valueSplit = currencyPair.Split(SeparatorCharacter);
19+
return new CurrencyPair(valueSplit[0], valueSplit[1]);
20+
}
21+
1422
public override string ToString()
1523
{
16-
return BaseCurrency + "_" + QuoteCurrency;
24+
return BaseCurrency + SeparatorCharacter + QuoteCurrency;
1725
}
1826

1927
public static bool operator ==(CurrencyPair a, CurrencyPair b)

Diff for: PoloniexApi.Net/Helper.cs

-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ internal static T DeserializeObject<T>(this JsonSerializer serializer, string va
5353
}
5454
}
5555

56-
internal static CurrencyPair ToCurrencyPair(this string value)
57-
{
58-
var valueSplit = value.Split('_');
59-
return new CurrencyPair(valueSplit[0], valueSplit[1]);
60-
}
61-
6256
internal static string ToHttpPostString(this Dictionary<string, object> dictionary)
6357
{
6458
var output = string.Empty;

Diff for: PoloniexApi.Net/LiveTools/Live.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Threading.Tasks;
5+
using System.Web;
56
using WampSharp.V2;
67

78
namespace Jojatekok.PoloniexAPI.LiveTools
@@ -51,7 +52,7 @@ public async Task SubscribeToTrollboxAsync()
5152

5253
private void ProcessMessageTicker(ISerializedValue[] arguments)
5354
{
54-
var currencyPair = arguments[0].Deserialize<string>().ToCurrencyPair();
55+
var currencyPair = CurrencyPair.Parse(arguments[0].Deserialize<string>());
5556
var priceLast = arguments[1].Deserialize<double>();
5657
var orderTopSell = arguments[2].Deserialize<double>();
5758
var orderTopBuy = arguments[3].Deserialize<double>();
@@ -86,7 +87,7 @@ private void ProcessMessageTrollbox(ISerializedValue[] arguments)
8687
var messageType = arguments[0].Deserialize<string>();
8788
var messageNumber = arguments[1].Deserialize<ulong>();
8889
var senderName = arguments[2].Deserialize<string>();
89-
var messageText = arguments[3].Deserialize<string>();
90+
var messageText = HttpUtility.HtmlDecode(arguments[3].Deserialize<string>());
9091
var senderReputation = arguments[4].Deserialize<uint>();
9192

9293
OnTrollboxMessage(this, new TrollboxMessageEventArgs(senderName, senderReputation, messageType, messageNumber, messageText));

Diff for: PoloniexApi.Net/MarketTools/Markets.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private IDictionary<CurrencyPair, IMarketData> GetSummary()
1919
{
2020
var data = GetData<IDictionary<string, MarketData>>("returnTicker");
2121
return data.ToDictionary(
22-
x => x.Key.ToCurrencyPair(),
22+
x => CurrencyPair.Parse(x.Key),
2323
x => (IMarketData)x.Value
2424
);
2525
}

Diff for: PoloniexApi.Net/PoloniexApi.Net.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Reference Include="System.Reactive.PlatformServices">
7070
<HintPath>..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath>
7171
</Reference>
72+
<Reference Include="System.Web" />
7273
<Reference Include="WampSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
7374
<SpecificVersion>False</SpecificVersion>
7475
<HintPath>..\packages\WampSharp.1.2.0.1-beta\lib\net45\WampSharp.dll</HintPath>

Diff for: PoloniexApi.Net/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
// You can specify all the values or you can default the Build and Revision Numbers
3030
// by using the '*' as shown below:
3131
// [assembly: AssemblyVersion("1.0.*")]
32-
[assembly: AssemblyVersion("1.1.0")]
33-
[assembly: AssemblyFileVersion("1.1.0")]
32+
[assembly: AssemblyVersion("1.1.1")]
33+
[assembly: AssemblyFileVersion("1.1.1")]
3434
[assembly: NeutralResourcesLanguageAttribute("en")]

0 commit comments

Comments
 (0)