示例#1
0
 /// <summary>
 /// Adds to service collection:
 ///     - specified options as singleton;
 ///     - <see cref="RestSerializer"/> as <see cref="IRestSerializer"/> as singleton;
 ///     - HttpClient with name <see cref="TradingRestClient.HttpClientName"/>;
 ///     - <see cref="ITradingRestClient"/>.
 /// </summary>
 /// <param name="services">Service collection to add client to.</param>
 /// <param name="options">Trading rest client options.</param>
 /// <param name="uri">Xena trading rest uri.</param>
 /// <returns>Populated service collection.</returns>
 public static IServiceCollection AddXenaTradingRestClient(
     this IServiceCollection services,
     TradingRestClientOptions options,
     string uri = "https://api.xena.exchange")
 {
     return(services
            .AddSingleton(options)
            .AddSingleton <IRestSerializer, RestSerializer>()
            .AddTransient <ITradingRestClient, TradingRestClient>()
            .AddHttpClient(RestClientBase.HttpClientName, client => client.BaseAddress = new Uri(uri))
            .Services);
 }
示例#2
0
        public void Setup()
        {
            var options = new TradingRestClientOptions
            {
                ApiKey    = ApiKey,
                ApiSecret = ApiSecret,
            };

            _restClient = new ServiceCollection()
                          .AddLogging(loggingBuilder =>
            {
                loggingBuilder.SetMinimumLevel(TestsLogLevel);
                loggingBuilder.AddConsole();
            })
                          .AddXenaTradingRestClient(options)
                          .BuildServiceProvider()
                          .GetService <ITradingRestClient>();
        }