public IRabbitExchange DeclareExchange(string name, ExchangeOptions options) { var exchange = new StubRabbitExchange(name, options, (o => null)); _exchangesDeclared.Add(exchange); return(exchange); }
public BaseExchange BaseExchange(string exchange) { IExchangeAPI api = ExchangeAPI.GetExchangeAPI(exchange.ToLower()); var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true); IConfiguration configuration = builder.Build(); ExchangeOptions exchangeOptions = new ExchangeOptions(); exchangeOptions.Exchange = (Exchange)Enum.Parse(typeof(Exchange), exchange, true); string apiKey; string apiSecret; //Check if there are multiple exchanges in config, else Fallback to single mode if (configuration.GetSection("Exchanges").GetSection(exchange) != null) { apiKey = configuration.GetSection("Exchanges").GetSection(exchange).GetValue <string>("ApiKey"); apiSecret = configuration.GetSection("Exchanges").GetSection(exchange).GetValue <string>("ApiSecret"); } else { apiKey = configuration.GetValue <string>("ApiKey"); apiSecret = configuration.GetValue <string>("ApiSecret"); } exchangeOptions.Exchange = (Exchange)Enum.Parse(typeof(Exchange), exchange, true); exchangeOptions.ApiKey = apiKey; exchangeOptions.ApiSecret = apiSecret; return(new BaseExchange(exchangeOptions)); }
public string Subscribe(ExchangeOptions exchangeOptions, QueueOptions queueOptions, bool autoAck) { amqpChannel = _amqpChannelProvider.GetAMQPChannel(); amqpChannel.ExchangeDeclare(exchangeOptions.Name, exchangeOptions.Type.ToString().ToLower(), exchangeOptions.Durable, exchangeOptions.AutoDelete); amqpChannel.QueueDeclare(queueOptions.Name, queueOptions.Durable, queueOptions.Exclusive, queueOptions.AutoDelete, null); var consumer = new EventingBasicConsumer(amqpChannel); consumer.Received += (sender, e) => { var messageBody = e.Body.ToArray(); var message = Encoding.UTF8.GetString(messageBody); }; amqpChannel.BasicConsume(queueOptions.Name, autoAck, consumer); }
/// <summary> /// Email Service contstructor configures the options necessary to send email with this implementation /// </summary> public EmailService(ILoggerFactory loggerFactory, IOptions <SendGridOptions> sendGridConfig, IOptions <ExchangeOptions> exchangeOptions) { _exchangeOptions = exchangeOptions.Value; _logger = loggerFactory.CreateLogger <DAO>(); //setup the config items to send messages _sendGridApiKey = sendGridConfig.Value.SendGridApiKey; _fromEmail = sendGridConfig.Value.FromEmail; }
public IRabbitExchange DeclareExchangeNoWait(string name, ExchangeOptions options) { EnsureNotDisposed(); var exchange = new StubRabbitExchange(name, options, (o => null)); _exchangesDeclaredNoWait.Add(exchange); return(exchange); }
public ActionResult Step2(ExchangeOptions options) { options.Date = DateTime.Now; // Добавляем информацию о заказе в базу данных. db.OrdersExchange.Add(options); // Сохраняем в БД все изменения. db.SaveChanges(); return(RedirectToAction("Step3", new { name = options.Name })); }
/// <summary> /// Configure the client using the provided options /// </summary> /// <param name="exchangeOptions">Options</param> protected void Configure(ExchangeOptions exchangeOptions) { log.UpdateWriters(exchangeOptions.LogWriters); log.Level = exchangeOptions.LogVerbosity; BaseAddress = exchangeOptions.BaseAddress; apiProxy = exchangeOptions.Proxy; if (apiProxy != null) { log.Write(LogVerbosity.Info, $"Setting api proxy to {exchangeOptions.Proxy.Host}:{exchangeOptions.Proxy.Port}"); } }
private TestImplementation PrepareClient(string responseData, bool withOptions = true, LogVerbosity verbosity = LogVerbosity.Warning, TextWriter tw = null) { var expectedBytes = Encoding.UTF8.GetBytes(responseData); var responseStream = new MemoryStream(); responseStream.Write(expectedBytes, 0, expectedBytes.Length); responseStream.Seek(0, SeekOrigin.Begin); var response = new Mock <IResponse>(); response.Setup(c => c.GetResponseStream()).Returns(responseStream); var request = new Mock <IRequest>(); request.Setup(c => c.Headers).Returns(new WebHeaderCollection()); request.Setup(c => c.Uri).Returns(new Uri("http://www.test.com")); request.Setup(c => c.GetResponse()).Returns(Task.FromResult(response.Object)); var factory = new Mock <IRequestFactory>(); factory.Setup(c => c.Create(It.IsAny <string>())) .Returns(request.Object); TestImplementation client; if (withOptions) { var options = new ExchangeOptions() { ApiCredentials = new ApiCredentials("Test", "Test2"), LogVerbosity = verbosity }; if (tw != null) { options.LogWriters = new List <TextWriter>() { tw } } ; client = new TestImplementation(options); } else { client = new TestImplementation(); } client.RequestFactory = factory.Object; return(client); }
public BaseExchange(ExchangeOptions options) { _exchange = options.Exchange; switch (_exchange) { case Exchange.Binance: _api = new ExchangeSharp.ExchangeBinanceAPI(); break; case Exchange.Bitfinex: _api = new ExchangeSharp.ExchangeBitfinexAPI(); break; case Exchange.Bittrex: _api = new ExchangeSharp.ExchangeBittrexAPI(); break; case Exchange.Poloniex: _api = new ExchangeSharp.ExchangePoloniexAPI(); break; case Exchange.Huobi: _api = new ExchangeSharp.ExchangeHuobiAPI(); break; case Exchange.HitBtc: _api = new ExchangeSharp.ExchangeHitbtcAPI(); break; case Exchange.Gdax: _api = new ExchangeSharp.ExchangeGdaxAPI(); break; case Exchange.Okex: _api = new ExchangeSharp.ExchangeOkexAPI(); break; case Exchange.Cryptopia: _api = new ExchangeSharp.ExchangeCryptopiaAPI(); break; case Exchange.Kucoin: _api = new ExchangeSharp.ExchangeKucoinAPI(); break; } _api.LoadAPIKeysUnsecure(options.ApiKey, options.ApiSecret, options.PassPhrase); }
public void DeclareBindExchangeAndQueues_GivenExchangeAndQueues_DeclaresAndBindsExchangesAndQueues() { var exchangeOptions = new ExchangeOptions("test", ExchangeType.Topic, Durability.Transient, AutoDeletion.Yes); var queueOne = new QueueOptions("Queue One", "queue.one", Durability.Transient, AutoDeletion.No, Exclusivity.No); var queueTwo = new QueueOptions("Queue two", "queue.two", Durability.Durable, AutoDeletion.Yes, Exclusivity.Yes); var queues = new[] { queueOne, queueTwo }; var subject = new RabbitMqConnectionService(ConnectionTestHelper.ValidConfiguration); subject.TestWithChannel(_noRetryOptions, (exchangeOptions.Name, queues.Select(x => x.Name)), channel => { subject.DeclareBindExchangeAndQueues(channel, exchangeOptions, queues) .ShouldBeSuccess(_ => { channel.ExchangeDeclarePassive(exchangeOptions.Name); channel.QueueDeclarePassive(queueOne.Name).QueueName.Should().Be(queueOne.Name); channel.QueueDeclarePassive(queueTwo.Name).QueueName.Should().Be(queueTwo.Name); }); }); }
public StubRabbitExchange(string name, ExchangeOptions options, Func <object, object> rpcFunc = null) { _rpcFunc = rpcFunc; this.Name = name; this.Options = options; this.DefaultSerializer = new StubRabbitSerializer(); _sendRaws = new List <Tuple <MessageEnvelope, string, SendOptions> >(); _sends = new List <Tuple <MessageEnvelope, string, SendOptions> >(); _sendRequestsRaw = new List <Tuple <MessageEnvelope, string, RpcSendOptions> >(); _sendRequests = new List <Tuple <MessageEnvelope, string, RpcSendOptions> >(); _queuesDeclared = new List <StubRabbitQueue>(); _queuesDeclaredNoWait = new List <StubRabbitQueue>(); _bindings = new List <StubRabbitQueueBinding>(); _bindingsNoWait = new List <StubRabbitQueueBinding>(); }
public void PublishMessage(ExchangeOptions exchangeOptions, string message, Dictionary <string, object> messageAttributes = null, string timeToLive = "30000") { byte[] messageBodyBytes = Encoding.UTF8.GetBytes(message); _amqpChannel.ExchangeDeclare(exchangeOptions.Name, exchangeOptions.Type.ToString().ToLower(), exchangeOptions.Durable, exchangeOptions.AutoDelete); IBasicProperties basicProperties = _amqpChannel.CreateBasicProperties(); basicProperties.DeliveryMode = 2; basicProperties.Persistent = true; basicProperties.Expiration = timeToLive; basicProperties.ContentType = "application/json"; if (messageAttributes is not null) { basicProperties.Headers = messageAttributes; } _amqpChannel.BasicPublish(exchangeOptions.Name, exchangeOptions.RoutingKey, basicProperties, messageBodyBytes); }
public void ReadEmailFromExchangeServer_ShouldReadOneItem() { var settings = new ExchangeSettings { ExchangeServerVersion = ExchangeServerVersion.Office365, UseAutoDiscover = true, Username = _userName, Password = _password, Mailbox = _mailbox }; var options = new ExchangeOptions { MaxEmails = 1, DeleteReadEmails = false, GetOnlyUnreadEmails = false, MarkEmailsAsRead = false, IgnoreAttachments = true }; var result = ReadEmailTask.ReadEmailFromExchangeServer(settings, options); Assert.That(result.Count, Is.EqualTo(1)); }
public static Uri GetUri(ExchangeOptions exchangeOptions, string calendar, DateTime start, DateTime end) { var builder = new UriBuilder(); builder.Scheme = exchangeOptions.Protocol; builder.Host = exchangeOptions.Server; builder.Path = $"{exchangeOptions.APIPath}/{calendar}/{exchangeOptions.Resource}"; var queryBuilder = new StringBuilder(); queryBuilder.Append("startDateTime="); queryBuilder.Append(start.ToString("yyyy-MM-dd") + "T" + start.ToString("HH:mm:ss")); queryBuilder.Append("&"); queryBuilder.Append("endDateTime="); queryBuilder.Append(end.ToString("yyyy-MM-dd") + "T" + end.ToString("HH:mm:ss")); queryBuilder.Append("&"); queryBuilder.Append("$select=Start,End"); queryBuilder.Append("&"); queryBuilder.Append("format=JSON"); builder.Query = queryBuilder.ToString(); return(builder.Uri); }
public IRabbitExchange DeclareExchangeNoWait(string name, ExchangeOptions options) { EnsureNotDisposed(); var exchange = new StubRabbitExchange(name, options, (o => null)); _exchangesDeclaredNoWait.Add(exchange); return exchange; }
public CobinhoodExchange(ExchangeOptions options) : base(options) { }
public TestRestClient(ExchangeOptions exchangeOptions) : base(exchangeOptions) { RequestFactory = new Mock <IRequestFactory>().Object; }
public ParseErrorTestRestClient(ExchangeOptions exchangeOptions) : base(exchangeOptions) { }
public CalendarClientFactory(IHttpClientFactory httpClientFactory, IOptionsMonitor <ExchangeOptions> exchangeOptions) { _httpClientFactory = httpClientFactory; _exchangeOptions = exchangeOptions.CurrentValue; }
protected RestClient(ExchangeOptions exchangeOptions) : base(exchangeOptions) { RequestTimeout = exchangeOptions.RequestTimeout; }
public BitfinexExchange(ExchangeOptions options) : base(options) { }
public CalendarClient(HttpClient httpClient, ExchangeOptions exchangeOptions, List <string> calendars) { _httpClient = httpClient; _exchangeOptions = exchangeOptions; _calendars = calendars; }
public PoloniexExchange(ExchangeOptions options) : base(options) { }
public IRabbitExchange DeclareExchange(string name, ExchangeOptions options) { var exchange = new StubRabbitExchange(name, options, (o => null)); _exchangesDeclared.Add(exchange); return exchange; }
public BaseExchange(ExchangeOptions options, ExchangeAPI exchangeApi) { _exchange = options.Exchange; _api = exchangeApi; }
internal BinanceExchangeBase(ExchangeOptions options) : base(options) { }
public BinanceExchangeRaw(ExchangeOptions options) : base(options) { }
internal ExchangeBase(ExchangeOptions options) { Options = options; http = Options.Http ?? new HttpClient(); mapper = Options.Mapper ?? throw new ArgumentNullException(nameof(Options.Mapper)); }
public TestImplementation(ExchangeOptions exchangeOptions) : base(exchangeOptions, exchangeOptions.ApiCredentials == null ? null : new TestAuthProvider(exchangeOptions.ApiCredentials)) { }
public ExchangeClient(IOptions <ExchangeOptions> fixerOptionsAccessor, IHttpClientFactory clientFactory) { _clientFactory = clientFactory; _exchangeOptions = fixerOptionsAccessor.Value; }
public void DefaultCoreSettings() { Global.CoreConfig["coreConfig"] = new JObject { ["enableDebug"] = false, ["enableDevelopment"] = false }; Global.CoreConfig["coreConfig"] = new JObject { ["webPort"] = 8888, ["webLocalHostOnly"] = false, ["webDefaultUsername"] = "******", ["webDefaultUserEmail"] = "admin@localhost", ["webDefaultPassword"] = "******" }; //Read Settings file if (!File.Exists(Global.DataPath + "/MainConfig.json")) { //Init Global Config with default currency array Global.Configuration = MergeObjects.MergeCsDictionaryAndSave(new MainConfig(), Global.DataPath + "/MainConfig.json").ToObject <MainConfig>(); Global.Configuration.TradeOptions.MarketBlackList = new List <string> { }; Global.Configuration.TradeOptions.OnlyTradeList = new List <string> { "ETHBTC", "LTCBTC" }; Global.Configuration.TradeOptions.AlwaysTradeList = new List <string> { "ETHBTC", "LTCBTC" }; var defaultExchangeOptions = new ExchangeOptions { Exchange = Exchange.Binance, ApiKey = "", ApiSecret = "" }; Global.Configuration.ExchangeOptions.Add(defaultExchangeOptions); var defaultDisplayOptions = new DisplayOptions() { DisplayFiatCurrency = "USD" }; Global.Configuration.DisplayOptions = defaultDisplayOptions; Global.Configuration = MergeObjects.MergeCsDictionaryAndSave(Global.Configuration, Global.DataPath + "/MainConfig.json", JObject.FromObject(Global.Configuration)).ToObject <MainConfig>(); } else { Global.Configuration = MergeObjects.MergeCsDictionaryAndSave(new MainConfig(), Global.DataPath + "/MainConfig.json").ToObject <MainConfig>(); } //Create RSA Key for TokenProvider if (string.IsNullOrEmpty(Global.Configuration.SystemOptions.RsaPrivateKey)) { using (RandomNumberGenerator rng = new RNGCryptoServiceProvider()) { byte[] tokenData = new byte[32]; rng.GetBytes(tokenData); Global.Configuration.SystemOptions.RsaPrivateKey = Convert.ToBase64String(tokenData); } Global.Configuration = MergeObjects.MergeCsDictionaryAndSave(Global.Configuration, Global.DataPath + "/MainConfig.json", JObject.FromObject(Global.Configuration)).ToObject <MainConfig>(); } }
protected BaseClient(ExchangeOptions options) { BaseAddress = options.BaseAddress; }