本文整理汇总了C#中IObservable.AsJson方法的典型用法代码示例。如果您正苦于以下问题:C# IObservable.AsJson方法的具体用法?C# IObservable.AsJson怎么用?C# IObservable.AsJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IObservable
的用法示例。
在下文中一共展示了IObservable.AsJson方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Connected
private static void Connected(IObservable<string> data)
{
ISubject<Trade> fakeTrades = new Subject<Trade>();
ISubject<DepthTable.Entry> fakeDepth = new Subject<DepthTable.Entry>();
ISubject<Ticker> fakeTicker = new Subject<Ticker>();
FakeExchange exchange = new FakeExchange(10, 0);
exchange.Subscribe(a => Console.Title = a.ToString());
IObservable<Ticker> ticker =
//fakeTicker;
data.AsJson().AsMtgoxTicker();
IObservable<DepthTable.Entry> depth =
//fakeDepth;
data.AsJson().AsMtgoxDepth();
IObservable<Trade> trade =
//fakeTrades;
data.AsJson().AsMtgoxTrades();
TradeManager manager = new TradeManager(exchange, ticker, depth, trade, new Stupid(5));
var tradelog = new StreamWriter(File.Open("trades.t", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read));
manager.Trades.Subscribe(a => tradelog.WriteLine(String.Format("tr {0} {1} {2}", a.Volume, a.Price, a.Date)));
manager.Trades.Subscribe(a => Console.WriteLine(String.Format("Mtgox Traded {0} BTC for {1} USD", a.Volume, a.Price)));
//while (true)
//{
// Console.WriteLine("Enter a line to inject fake data");
// Console.WriteLine("tr {volume} {price}");
// var line = Console.ReadLine();
// line = trFile.ReadLine();
// var tokens = line.Split(' ').Select(a => a.ToLower()).ToArray();
// if (tokens[0] == "tr" && tokens.Length == 3)
// {
// fakeTrades.OnNext(new Trade(decimal.Parse(tokens[1]), decimal.Parse(tokens[2]), DateTime.Now.ToUniversalTime().Ticks));
// }
//}
Console.WriteLine("Press any key to exit");
Console.Read();
//tradelog.Flush();
//tradelog.Close();
}