private static LinkRepository InitializeCosmosClientInstance(LinkConfig linkConfig) { Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder clientBuilder = new Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder(linkConfig.ConnectionString); Microsoft.Azure.Cosmos.CosmosClient client = clientBuilder .WithConnectionModeDirect() .Build(); LinkRepository linkRepository = new LinkRepository(client, linkConfig.DatabaseName, linkConfig.ContainerName); return(linkRepository); }
private void Configure() { this.numericUpDownSource.Value = LinkConfig.GetDefaultSourceAddress(isMaster); this.numericUpDownDest.Value = LinkConfig.GetDefaultDestinationAddress(isMaster); this.numericUpDownTimeout.Value = LinkConfig.DefaultTimeoutMillisconds; this.numericUpDownRetries.Value = LinkConfig.DefaultNumRetries; this.checkBoxConfirmed.Checked = false; this.SetState(); }
private void Configure(LinkConfig config) { this.isMaster = config.isMaster; this.numericUpDownSource.Value = config.localAddr; this.numericUpDownDest.Value = config.remoteAddr; this.numericUpDownTimeout.Value = config.timeoutMs; this.numericUpDownRetries.Value = config.numRetry; this.checkBoxConfirmed.Checked = config.useConfirms; this.SetState(); }
//private void SetState() //{ // this.groupBoxConfirmed.Enabled = this.checkBoxConfirmed.Checked; //} private void Configure(LinkConfig config) { isMaster = config.isMaster; LocalAddr = config.localAddr; RemoteAddr = config.remoteAddr; ResponseTimeout = Convert.ToDecimal(config.responseTimeout.TotalMilliseconds); // this.numericUpDownRetries.Value = config.numRetry; // UseConfirms = config.us.useConfirms; KeepAliveTimeout = Convert.ToDecimal(config.keepAliveTimeout.TotalMilliseconds); //this.SetState(); }
private void Configure(LinkConfig config) { this.isMaster = config.isMaster; this.numericUpDownSource.Value = config.localAddr; this.numericUpDownDest.Value = config.remoteAddr; this.numericUpDownTimeout.Value = Convert.ToDecimal(config.responseTimeout.TotalMilliseconds); this.numericUpDownRetries.Value = config.numRetry; this.checkBoxConfirmed.Checked = config.useConfirms; this.numericUpDownKeepAliveTimeout.Value = Convert.ToDecimal(config.keepAliveTimeout.TotalMilliseconds); this.SetState(); }
public override ConsoleControl FindControlByAddress(string address) { ConsoleControl c; c = FindAddressFromList(ChannelLink, address); if (c == null) { c = FindAddressFromList(AuxLink, address); if (c == null) { c = FindAddressFromList(FxLink, address); if (c == null) { c = FindAddressFromList(BusLink, address); if (c == null) { c = FindAddressFromList(MatrixLink, address); if (c == null) { c = LinkConfig.FindControlByAddress(Address); if (c == null) { c = MonoConfig.FindControlByAddress(Address); if (c == null) { c = SoloConfig.FindControlByAddress(Address); if (c == null) { c = Talkback.FindControlByAddress(Address); if (c == null) { c = TapeConfig.FindControlByAddress(address); if (c == null) { } } } } } } } } } } return(c); }
public override void Configure(IFunctionsHostBuilder builder) { // We need to get the app directory this way. Using Environment.CurrentDirectory doesn't work in Azure ExecutionContextOptions executioncontextoptions = builder.Services.BuildServiceProvider() .GetService <IOptions <ExecutionContextOptions> >().Value; string currentDirectory = executioncontextoptions.AppDirectory; IConfigurationBuilder configBuilder = new ConfigurationBuilder() .SetBasePath(currentDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); IConfigurationRoot config = configBuilder.Build(); // DI doesn't work in startup PollyHttpPolicies pollyHttpPolicies = new PollyHttpPolicies(new PollyHttpPoliciesConfig()); Dictionary <HttpClientConfigName, ApiConfig> httpClientConfigs = config.GetSection("Apis").Get <Dictionary <HttpClientConfigName, ApiConfig> >(); foreach (KeyValuePair <HttpClientConfigName, ApiConfig> httpClientConfig in httpClientConfigs) { IAsyncPolicy <HttpResponseMessage> retryPolicy = httpClientConfig.Value.IsExternal ? pollyHttpPolicies.ExternalHttpRetryPolicy : pollyHttpPolicies.InternalHttpRetryPolicy; builder.Services.AddHttpClient(httpClientConfig.Key.ToString(), c => { c.BaseAddress = new Uri(httpClientConfig.Value.BaseAddress); c.Timeout = httpClientConfig.Value.Timeout ?? new TimeSpan(0, 0, 0, 15); foreach (KeyValuePair <string, string> header in httpClientConfig.Value.Headers) { c.DefaultRequestHeaders.Add(header.Key, header.Value); } c.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); c.DefaultRequestHeaders.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate")); }).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { MaxConnectionsPerServer = httpClientConfig.Value.MaxConnectionsPerServer ?? 15, AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }).AddPolicyHandler(retryPolicy); } IConfigurationSection emailConfigSettings = config.GetSection("EmailConfig"); builder.Services.Configure <EmailConfig>(emailConfigSettings); IConfigurationSection serviceBusConfigSettings = config.GetSection("ServiceBusConfig"); builder.Services.Configure <ServiceBusConfig>(serviceBusConfigSettings); ServiceBusConfig serviceBusConfig = serviceBusConfigSettings.Get <ServiceBusConfig>(); IConfigurationSection sendGridConfigSettings = config.GetSection("SendGridConfig"); builder.Services.Configure <SendGridConfig>(sendGridConfigSettings); var sendGridConfig = config.GetSection("SendGridConfig").Get <SendGridConfig>(); builder.Services.AddSingleton <ISendGridClient>(new SendGridClient(sendGridConfig.ApiKey)); builder.Services.AddTransient <IHttpClientWrapper, HttpClientWrapper>(); builder.Services.AddMediatR(typeof(SendEmailHandler).Assembly); builder.Services.AddAutoMapper(typeof(AddressDetailsProfile).Assembly); builder.Services.AddSingleton <IQueueClient>(new QueueClient(serviceBusConfig.ConnectionString, serviceBusConfig.MessageQueueName)); builder.Services.AddSingleton <IMessageFactory, MessageFactory>(); //builder.Services.AddSingleton<IConnectSendGridService, SendGridService>(); builder.Services.AddSingleton <ISendEmailService, SendEmailService>(); builder.Services.AddSingleton <IConnectUserService, ConnectUserService>(); builder.Services.AddSingleton <IConnectRequestService, ConnectRequestService>(); builder.Services.AddSingleton <IConnectGroupService, ConnectGroupService>(); builder.Services.AddTransient <IJobFilteringService, JobFilteringService>(); builder.Services.AddSingleton <IConnectAddressService, ConnectAddressService>(); builder.Services.AddSingleton <IConnectSendGridService, ConnectSendGridService>(); builder.Services.AddSingleton <IDistanceCalculator, DistanceCalculator>(); builder.Services.AddSingleton <IPurgeService, PurgeService>(); builder.Services.AddDbContext <ApplicationDbContext>(options => options.UseInMemoryDatabase(databaseName: "CommunicationService.AzureFunction")); builder.Services.AddTransient <IRepository, Repository>(); CosmosConfig cosmosConfig = config.GetSection("CosmosConfig").Get <CosmosConfig>(); builder.Services.AddSingleton <ICosmosDbService>(InitializeCosmosClientInstance(cosmosConfig)); InterUserMessageConfig interUserMessageConfig = config.GetSection("InterUserMessageConfig").Get <InterUserMessageConfig>(); builder.Services.AddSingleton <IInterUserMessageRepository>(InitializeCosmosClientInstance(interUserMessageConfig)); IConfigurationSection linkConfigSettings = config.GetSection("LinkConfig"); builder.Services.Configure <LinkConfig>(linkConfigSettings); LinkConfig linkConfig = config.GetSection("LinkConfig").Get <LinkConfig>(); builder.Services.AddSingleton <ILinkRepository>(InitializeCosmosClientInstance(linkConfig)); SendGridManagement.EmailTemplateUploader emailTemplateUploader = new SendGridManagement.EmailTemplateUploader(new SendGridClient(sendGridConfig.ApiKey), InitializeCosmosClientInstance(cosmosConfig)); builder.Services.AddSingleton <IPollyMemoryCacheProvider, PollyMemoryCacheProvider>(); builder.Services.AddMemCache(); builder.Services.AddSingleton(x => x.GetService <IMemDistCacheFactory <LocationDetails> >().GetCache(new TimeSpan(30, 0, 0, 0), ResetTimeFactory.OnMidday)); builder.Services.AddSingleton(x => x.GetService <IMemDistCacheFactory <Template> >().GetCache(new TimeSpan(30, 0, 0, 0), ResetTimeFactory.OnMidday)); builder.Services.AddSingleton(x => x.GetService <IMemDistCacheFactory <UnsubscribeGroup> >().GetCache(new TimeSpan(30, 0, 0, 0), ResetTimeFactory.OnMidday)); emailTemplateUploader.Migrate().ConfigureAwait(false); }
protected BaseConnection(LinkConfig config) { Config = config; }
public WebSocketConnection(LinkConfig config) : base(config) { _ws = new ClientWebSocket(); _tokenSource = new CancellationTokenSource(); }
public static async Task <int> Main(string[] args) { LinkConfig.Setup(); return(await LinkCommandLine.Run(args)); }