示例#1
0
        public async Task <PairRate[]> GetRatesAsync(CancellationToken cancellationToken)
        {
            var response = await _httpClient.GetAsync("https://api.hitbtc.com/api/2/public/ticker", cancellationToken);

            var jarray = await response.Content.ReadAsAsync <JArray>(cancellationToken);

            return(jarray
                   .Children <JObject>()
                   .Where(p => CurrencyPair.TryParse(p["symbol"].Value <string>(), out _))
                   .Select(p => new PairRate(CurrencyPair.Parse(p["symbol"].Value <string>()), CreateBidAsk(p)))
                   .ToArray());
        }
示例#2
0
 public override SyntaxNode VisitIdentifierName(IdentifierNameSyntax node)
 {
     if (CurrencyPair.TryParse(node.Identifier.ValueText, out var currencyPair))
     {
         return(SyntaxFactory.IdentifierName(currencyPair.ToString())
                .WithTriviaFrom(node));
     }
     else
     {
         Errors.Add(RateRulesErrors.InvalidCurrencyIdentifier);
         return(base.VisitIdentifierName(node));
     }
 }
示例#3
0
 public override void VisitAssignmentExpression(AssignmentExpressionSyntax node)
 {
     if (node.Kind() == SyntaxKind.SimpleAssignmentExpression &&
         node.Left is IdentifierNameSyntax id &&
         node.Right is ExpressionSyntax expression)
     {
         if (CurrencyPair.TryParse(id.Identifier.ValueText, out var currencyPair))
         {
             expression = expression.WithTriviaFrom(expression);
             ExpressionsByPair.TryAdd(currencyPair, (expression, id));
         }
     }
     base.VisitAssignmentExpression(node);
 }