private static void RegisterPlugins(RegistryConfiguration configuration, IServiceCollection services) { var registry = new PluginRegistry(); var plugins = configuration.Plugins; foreach (var plugin in plugins) { var manufacturer = plugin.Manufacturer !; var namesElement = plugin.Names; foreach (var nameElement in namesElement) { var name = nameElement.Name !; var implicitAlias = manufacturer + " " + name; registry.Register(name, manufacturer, implicitAlias); if (nameElement.Aliases.Any()) { registry.Register(name, manufacturer, nameElement.Aliases); } } } services.AddSingleton <IPluginRegistry>(registry); }
/// <summary> /// Initializes a new instance of the <see cref="RegistryService"/> class. /// </summary> /// <param name="registryConfigurationOptions">The registry configuration options.</param> /// <param name="messageSerializer">The message serializer.</param> /// <param name="serviceMessageProcessor">The service message processor.</param> /// <param name="messageToServiceMapper">The message to service mapper.</param> /// <param name="messageTypeCache">The message type cache.</param> /// <param name="accessTokenService">The access token service.</param> /// <param name="registryServiceLogger">The registry service logger.</param> /// <param name="tcpNetworkConnectorLogger">The tcp network connector logger.</param> /// <param name="registryServiceMessageProcessorLogger">The registry service message processor logger.</param> /// <param name="httpNetworkConnectorLogger">The http network connector logger.</param> public RegistryService( IOptions <RegistryConfiguration> registryConfigurationOptions, IMessageSerializer messageSerializer, IServiceMessageProcessor serviceMessageProcessor, IMessageToServiceMapper messageToServiceMapper, IRegistryServiceMessageTypeCache messageTypeCache, IAccessTokenService accessTokenService, ILogger <RegistryService> registryServiceLogger, ILogger <TcpNetworkConnector> tcpNetworkConnectorLogger, ILogger <RegistryServiceMessageProcessor> registryServiceMessageProcessorLogger, ILogger <HttpNetworkConnector> httpNetworkConnectorLogger) { _messageSerializer = messageSerializer; _serviceMessageProcessor = serviceMessageProcessor; _registryServiceMessageProcessor = new RegistryServiceMessageProcessor(this, registryServiceMessageProcessorLogger); _messageToServiceMapper = messageToServiceMapper; RegistryConfiguration registryConfiguration = registryConfigurationOptions.Value; _tcpListener = new TcpListener(IPAddress.Any, registryConfiguration.Port); _messageTypeCache = messageTypeCache; _accessTokenService = accessTokenService; _registryServiceLogger = registryServiceLogger; _tcpNetworkConnectorLogger = tcpNetworkConnectorLogger; _httpNetworkConnectorLogger = httpNetworkConnectorLogger; }
public void Arrange() { _restClientMock = new Mock <IRestClient>(); _restClientMock.Setup(c => c.ExecuteTaskAsync(It.IsAny <RestRequest>(), _cancellationToken)) .ReturnsAsync(new RestResponse { Content = JsonConvert.SerializeObject(new GetSynonymsResult { Synonyms = new EntityReference[0], }), StatusCode = HttpStatusCode.OK, ResponseStatus = ResponseStatus.Completed, }); _configuration = new RegistryConfiguration { RegistryApiBaseUrl = "https://search.example.com/", }; _executionContextManager = new Mock <ISpiExecutionContextManager>(); _executionContextManager.Setup(m => m.SpiExecutionContext) .Returns(new SpiExecutionContext()); _loggerMock = new Mock <ILoggerWrapper>(); _provider = new RegistryApiRegistryProvider( _restClientMock.Object, _configuration, _executionContextManager.Object, _loggerMock.Object); _cancellationToken = new CancellationToken(); }
private static void RegisterNamingServices(IServiceCollection services) { var configuration = new RegistryConfiguration(); var section = Configuration?.GetSection(RegistryConfiguration.SectionName); section.Bind(configuration); RegisterPlugins(configuration, services); }
private void AddConfiguration(IServiceCollection services, IConfigurationRoot rawConfiguration) { services.AddSingleton(rawConfiguration); var configuration = new RegistryConfiguration(); rawConfiguration.Bind(configuration); services.AddSingleton(configuration); services.AddSingleton(configuration.Sync); services.AddSingleton(configuration.Data); }
static void Main() { RegistryConfiguration.ConfigureRegistry(); XmlConfigurator.Configure(); using (var game = new ASummonersTaleGame()) { if (!game.Components.Any()) { return; } game.Run(); } }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { var hive = (string)config[nameof(RegistryConfiguration.Hive)]; if (Enum.TryParse <RegistryHive>(hive, true, out var h)) { hive = h.GetAbbreviation(); } return(new ExtendedRichDescription( new RichDescription( "Ensure Registry Key ", new Hilite(h + "\\" + RegistryConfiguration.GetCanonicalKey(config[nameof(RegistryConfiguration.Key)])) ), new RichDescription( string.Equals(config[nameof(RegistryConfiguration.Exists)], "false", StringComparison.OrdinalIgnoreCase) ? "does not exist" : "exists" ) )); }
protected override ExtendedRichDescription GetDescription(IOperationConfiguration config) { var hive = (string)config[nameof(Hive)]; if (Enum.TryParse <RegistryHive>(hive, true, out var h)) { hive = h.GetAbbreviation(); } return(new ExtendedRichDescription( new RichDescription( "Store Registry Value ", new Hilite(config[nameof(ValueName)]), " to ", new Hilite(config[nameof(Value)]) ), new RichDescription( "from key ", new Hilite(h + "\\" + RegistryConfiguration.GetCanonicalKey(config[nameof(Key)])) ) )); }
public RegistryApiRegistryProvider( IRestClient restClient, RegistryConfiguration configuration, ISpiExecutionContextManager executionContextManager, ILoggerWrapper logger) { _restClient = restClient; _executionContextManager = executionContextManager; _restClient.BaseUrl = new Uri(configuration.RegistryApiBaseUrl, UriKind.Absolute); if (!string.IsNullOrEmpty(configuration.RegistryApiFunctionKey)) { _restClient.DefaultParameters.Add(new Parameter(CommonHeaderNames.AzureFunctionKeyHeaderName, configuration.RegistryApiFunctionKey, ParameterType.HttpHeader)); } if (!string.IsNullOrEmpty(configuration.RegistryApiSubscriptionKey)) { _restClient.DefaultParameters.Add(new Parameter(CommonHeaderNames.EapimSubscriptionKeyHeaderName, configuration.RegistryApiSubscriptionKey, ParameterType.HttpHeader)); } _logger = logger; }