本文整理汇总了C#中Exchange.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Exchange.ToString方法的具体用法?C# Exchange.ToString怎么用?C# Exchange.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exchange
的用法示例。
在下文中一共展示了Exchange.ToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConnectTo
public IConnection ConnectTo(Exchange exchange)
{
_log.Debug("Getting connection for exchange: " + exchange.ToString());
IConnection connection = null;
// first, see if we have a cached connection
if (_connections.ContainsKey(exchange))
{
connection = _connections[exchange];
if (!connection.IsOpen)
{
_log.Info("Cached connection to RabbitMQ was closed: reconnecting");
connection = this.CreateConnection(exchange);
}
}
else
{
_log.Debug("No connection to the exchange was cached: creating");
connection = this.CreateConnection(exchange);
// add the new connection to the cache
_connections[exchange] = connection;
}
return connection;
}
示例2: Main
/// <summary>
/// Application arguments:
/// arg0: Selected Exchange. Has to be enum StockModel.Master.Exchange
/// arg1: Data generator to use. Has to be IDataPublisher.
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
//Loading system startup data for all the exchanges
List<Exchange> exchanges = new List<Exchange>();
//defaults selected...
selectedExchange = Exchange.FAKE_NASDAQ;
dataGenerator = YahooDataGenerator.Instance;
ResolveAppArgs(args);
exchanges = Enum.GetValues(typeof(Exchange)).OfType<Exchange>().ToList();
InMemoryObjects.LoadInMemoryObjects(exchanges);
TimeSpan updateDuration = TimeSpan.FromMilliseconds(Constants.FAKE_DATA_GENERATE_PERIOD);
//Start data generation - this will start fetching data for all symbols of current exchange
//Later, need to change this to only subscribe to the specific symbol(s) selected.
dataGenerator.StartDataGeneration(300, selectedExchange);
sender = SenderFactory.GetSender(FeederQueueSystem.REDIS_CACHE);
List<StockModel.Symbol> symbols = InMemoryObjects.ExchangeSymbolList.SingleOrDefault(x => x.Exchange == selectedExchange).Symbols;
List<SymbolFeeds> generatedData = new List<SymbolFeeds>();
List<StockModel.Symbol> symbolList = new List<StockModel.Symbol>();
Action<double, string> addMovingAverage = new Action<double, string>((val,MVA_id) => {
sender.SendMVA(val, MVA_id);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Sent value {0} to redis", val);
Console.ResetColor();
});
Parallel.ForEach(symbols, (symbol) =>
{
//subscribe
dataGenerator.SubscribeFeed(symbol.Id, (Feed fd) =>
{
sender.SendFeed(fd, selectedExchange.ToString());
Console.WriteLine(fd.ToString());
});
//add subscription for each aggregator configured
//RXProcessing.AddAggregator(dataGenerator, new MovingAverage(),
// addMovingAverage
// , symbol.Id);
});
Console.Read();
}
示例3: GetSymbolForMarket
public static List<StockModel.Symbol> GetSymbolForMarket(Exchange exchange)
{
// Method to get all the company names & their symbols and set their default value & Id
int i = 1;
Random random = new Random();
List<StockModel.Symbol> symbols = new List<StockModel.Symbol>();
string jsonString;
string symbolFilePath = string.Empty;
//exchange specific symbol file paths are configured
symbolFilePath = WebConfigurationManager.AppSettings[exchange.ToString() + "_SymbolFilePath"];
//exchange specific symbol file paths are not configured. Pick Defaults.
if (string.IsNullOrEmpty(symbolFilePath))
{
symbolFilePath = WebConfigReader.Read("SymbolFilePath");
}
jsonString = System.IO.File.ReadAllText(symbolFilePath);
JArray jsonArray = JsonConvert.DeserializeObject<JArray>(jsonString);
foreach (JObject jsonObject in jsonArray)
{
StockModel.Symbol symbol = new StockModel.Symbol();
foreach (var property in jsonObject)
{
if (property.Key == "Name")
{
symbol.SymbolName = property.Value.ToString();
}
if (property.Key == "Symbol")
{
symbol.SymbolCode = property.Value.ToString();
}
symbol.DefaultVal = random.NextDouble() * 1000;
symbol.Id = i;
}
i = i + 1;
symbols.Add(symbol);
}
return symbols;
}