Beispiel #1
0
        public void ConfigureContainer(ContainerBuilder builder)
        {
            string currentDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            var configBuilder = new ConfigurationBuilder()
                                .SetBasePath(currentDirectory)
                                .AddJsonFile("appsettings.json")
                                .AddEnvironmentVariables();

            //Deal with the configuration bits
            var config = configBuilder.Build();

            builder.RegisterInstance(config);

            string dbConnectionString = config["DEVICEAPI_CONNSTRING"];

            // Add things to the Autofac ContainerBuilder.
            builder.RegisterInstance(new SqlServerDbConnectionFactory(dbConnectionString))
            .As <IDbConnectionFactory>()
            .SingleInstance();

            var registryConfig = new RegistryConfig()
            {
                RegistryHost = config["DEVICEAPI_REGISTRYHOST"]
            };

            builder.RegisterInstance(registryConfig);

            builder.RegisterType <RepositoryNameFactory>().SingleInstance();
        }
 public DeviceConfigurationController(
     IDbConnectionFactory connectionFactory,
     RegistryConfig registryConfig,
     ProvisioningConfig provisioningConfig)
 {
     _connectionFactory  = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
     _provisioningConfig = provisioningConfig ?? throw new ArgumentNullException(nameof(provisioningConfig));
 }
Beispiel #3
0
 /// <inheritdoc/>
 public ApiConfig(IConfiguration configuration) :
     base(configuration)
 {
     _twin      = new TwinConfig(configuration);
     _registry  = new RegistryConfig(configuration);
     _publisher = new PublisherConfig(configuration);
     _events    = new EventsConfig(configuration);
 }
Beispiel #4
0
 public AgentUploadInfoController(
     IDbConnectionFactory connectionFactory,
     RegistryConfig registryConfig,
     RepositoryNameFactory repositoryNameFactory)
 {
     _connectionFactory     = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
     _registryConfig        = registryConfig ?? throw new ArgumentNullException(nameof(registryConfig));
     _repositoryNameFactory = repositoryNameFactory;
 }
        public IConfig AddConfig(string name, RegistryKey key) {
            RegistryConfig result = new RegistryConfig(name, this);
            result.Key = key;
            result.ParentKey = true;

            Configs.Add(result);

            return result;
        }
Beispiel #6
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfiguration configuration) :
     base(configuration)
 {
     _auth     = new AuthConfig(configuration);
     _host     = new HostConfig(configuration);
     _hub      = new IoTHubConfig(configuration);
     _cors     = new CorsConfig(configuration);
     _sessions = new SessionServicesConfig(configuration);
     _api      = new RegistryConfig(configuration);
 }
Beispiel #7
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 public Config(IConfiguration configuration) :
     base(configuration)
 {
     _host     = new WebHostConfig(configuration);
     _hub      = new IoTHubConfig(configuration);
     _cors     = new CorsConfig(configuration);
     _sessions = new SessionServicesConfig(configuration);
     _api      = new RegistryConfig(configuration);
     _fh       = new ForwardedHeadersConfig(configuration);
 }
 /// <summary>
 /// Removes all keys not present in the current config.
 /// </summary>
 private void RemoveKeys(RegistryConfig config)
 {
     foreach (string valueName in config.Key.GetValueNames())
     {
         if (!config.Contains(valueName))
         {
             config.Key.DeleteValue(valueName);
         }
     }
 }
Beispiel #9
0
 public ApplicationDownloadInfoController(
     IDbConnectionFactory connectionFactory,
     ILogger <ApplicationDownloadInfoController> logger,
     RegistryConfig registryConfig,
     RepositoryNameFactory repositoryNameFactory)
 {
     _logger                = logger ?? throw new ArgumentNullException(nameof(logger));
     _registryConfig        = registryConfig ?? throw new ArgumentNullException(nameof(registryConfig));
     _repositoryNameFactory = repositoryNameFactory ?? throw new ArgumentNullException(nameof(repositoryNameFactory));
     _connectionFactory     = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
 }
        /// <include file='RegistryConfigSource.xml' path='//Method[@name="AddConfigKey"]/docs/*' />
        public IConfig AddConfig(string name, RegistryKey key)
        {
            RegistryConfig result = new RegistryConfig(name, this);

            result.Key       = key;
            result.ParentKey = true;

            this.Configs.Add(result);

            return(result);
        }
Beispiel #11
0
 /// <inheritdoc/>
 public ApiConfig(IConfiguration configuration) :
     base(configuration)
 {
     _twin      = new TwinConfig(configuration);
     _registry  = new RegistryConfig(configuration);
     _jobs      = new JobsServiceConfig(configuration);
     _vault     = new VaultConfig(configuration);
     _history   = new HistoryConfig(configuration);
     _publisher = new PublisherConfig(configuration);
     _signalR   = new SignalRClientConfig(configuration);
 }
        /// <summary>
        /// Loads all values from the registry key.
        /// </summary>
        private void LoadKeyValues(RegistryKey key, string keyName)
        {
            RegistryConfig config = new RegistryConfig(keyName, this);

            config.Key = key;

            string[] values = key.GetValueNames();
            foreach (string value in values)
            {
                config.Add(value, key.GetValue(value).ToString());
            }
            this.Configs.Add(config);
        }
Beispiel #13
0
        static void Main(string[] args)
        {
            var protocol = new ProtocolConfig
            {
                Name      = "dubbo",
                Serialize = "fastjson"
            };
            var registryConfig = new RegistryConfig("consul://127.0.0.1:8500");

            DubboApplication.Init(protocol, registryConfig);
            RequestTest(20000, true);

            Console.ReadLine();
        }
Beispiel #14
0
 /// <summary>
 /// Configuration constructor
 /// </summary>
 /// <param name="configuration"></param>
 internal Config(IConfiguration configuration) :
     base(configuration)
 {
     _vault    = new VaultConfig(configuration);
     _keyVault = new KeyVaultConfig(configuration);
     _cosmos   = new CosmosDbConfig(configuration);
     _openApi  = new OpenApiConfig(configuration);
     _host     = new WebHostConfig(configuration);
     _cors     = new CorsConfig(configuration);
     _sb       = new ServiceBusConfig(configuration);
     _hub      = new IoTHubConfig(configuration);
     _registry = new RegistryConfig(configuration);
     _fh       = new ForwardedHeadersConfig(configuration);
 }
        /// <summary>
        /// Loads all values from the registry key.
        /// </summary>
        private void LoadKeyValues(RegistryKey key, string keyName)
        {
            var config = new RegistryConfig(keyName, this)
            {
                Key = key
            };

            var values = key.GetValueNames();

            foreach (var value in values)
            {
                config.Add(value, key.GetValue(value).ToString());
            }
            Configs.Add(config);
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            var protocol = new ProtocolConfig
            {
                Name      = "dubbo",
                Serialize = "fastjson"
            };
            var registryConfig = new RegistryConfig("consul://127.0.0.1:8500");

            DubboApplication.Init(protocol, registryConfig);
            //ObjectFactory.Register<ILogger,ConsoleLog>();
            //ObjectFactory.Register<IConfigUtils, CacheConfigUtil>();
            RequestTest(20000, true);

            Console.ReadLine();
        }
        /// <include file='IConfigSource.xml' path='//Method[@name="Save"]/docs/*' />
        public override void Save()
        {
            MergeConfigsIntoDocument();

            for (int i = 0; i < this.Configs.Count; i++)
            {
                // New merged configs are not RegistryConfigs
                if (this.Configs[i] is RegistryConfig)
                {
                    RegistryConfig config = (RegistryConfig)this.Configs[i];
                    string[]       keys   = config.GetKeys();

                    for (int j = 0; j < keys.Length; j++)
                    {
                        config.Key.SetValue(keys[j], config.Get(keys[j]));
                    }
                }
            }
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="MainWindowViewModel" /> class.
        /// </summary>
        /// <param name="config">The current launcher config,</param>
        /// <param name="registry">The registry config object.</param>
        /// <param name="updater">The instance of the <see cref="Updater" /> class that is used to check for and execute updates.</param>
        /// <param name="resourceManager">
        ///     The instance of the resource manager that should be used to provide resource strings for
        ///     the view.
        /// </param>
        public MainWindowViewModel(
            ILauncherConfig config,
            RegistryConfig registry,
            Updater updater,
            ResourceManager resourceManager)
            : base(resourceManager)
        {
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (updater == null)
            {
                throw new ArgumentNullException(nameof(updater));
            }

            this.config   = config;
            this.registry = registry;
            this.UpdateVersionText();
            this.SelectedTabIndex            = config.SelectedTabIndex > 0 ? config.SelectedTabIndex : 0;
            updater.AvailableUpdateDetected += (obj, args) => updater.Update();
            updater.ErrorOccured            += this.UpdaterErrorOccured;
            updater.DownloadStarted         += (obj, args) => this.UpdateRunning = true;
            updater.UpdateCompleted         += (obj, args) =>
            {
                this.UpdateRunning = false;
                this.UpdateVersionText();
                updater.Check();
            };

            updater.DownloadProgress += this.UpdaterDownloadProgress;
            updater.Check();
            this.updater = updater;
        }
Beispiel #19
0
        /// <summary>
        /// 初始化Dubbo消费端
        /// </summary>
        public static void Init(ProtocolConfig protocol, RegistryConfig registryConfig)
        {
            DependencyRegistor.Register("Dubbo.Net.Proxy");
            var registryUrl     = URL.ValueOf(registryConfig.ToRegistryString());
            var registryFactory = ObjectFactory.GetInstance <IRegistryFactory>(registryUrl.Protocol);
            var registry        = registryFactory.GetRegistry(registryUrl);
            var assemblies      = AppDomain.CurrentDomain.GetAssemblies();
            var generator       = ObjectFactory.GetInstance <IServiceProxyGenerater>();
            var types           = new List <Type>();

            foreach (var assembly in assemblies)
            {
                var ts = assembly.GetTypes();
                foreach (var type in ts)
                {
                    if (!type.IsInterface)
                    {
                        continue;
                    }
                    var attr = type.GetCustomAttribute <ReferAttribute>();
                    if (attr != null)
                    {
                        types.Add(type);
                    }
                }
            }

            foreach (var type in types)
            {
                TypeMatch.RegisterType(type);
                var url     = ReferenceConfig.Init(type, registryConfig, protocol);
                var impl    = generator.GenerateProxys(type);
                var ctor    = impl.GetConstructor(new[] { typeof(URL) });
                var service = ctor.Invoke(new object[] { url });
                ObjectFactory.Register(type, impl);
                ObjectFactory.Register(impl, service);
                registry.Subscribe(url.ServiceName).Wait();
            }
            registry.Start();
        }
        /// <summary>
        /// Merges all of the configs from the config collection into the
        /// registry.
        /// </summary>
        private void MergeConfigsIntoDocument()
        {
            foreach (IConfig config in this.Configs)
            {
                if (config is RegistryConfig)
                {
                    RegistryConfig registryConfig = (RegistryConfig)config;

                    if (registryConfig.ParentKey)
                    {
                        registryConfig.Key =
                            registryConfig.Key.CreateSubKey(registryConfig.Name);
                    }
                    RemoveKeys(registryConfig);

                    string[] keys = config.GetKeys();
                    for (int i = 0; i < keys.Length; i++)
                    {
                        registryConfig.Key.SetValue(keys[i], config.Get(keys[i]));
                    }
                    registryConfig.Key.Flush();
                }
            }
        }
Beispiel #21
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="App" /> class.
        /// </summary>
        public App()
        {
            AppDomain.CurrentDomain.UnhandledException += this.CurrentDomainUnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += this.CurrentDomainProcessExit;
            if (!this.mutex.WaitOne())
            {
                // The application is already running.
                Environment.Exit(1);
            }

            this.config = this.LoadConfig();
            if (!string.IsNullOrEmpty(this.config.SelectedLanguage))
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(this.config.SelectedLanguage);
            }
            else
            {
                this.config.SelectedLanguage = Thread.CurrentThread.CurrentCulture.Name;
            }

            CultureInfo fallbackCultureInfo = CultureInfo.GetCultureInfo("EN-us");

            this.resourceManager = new ResourceManager(Thread.CurrentThread.CurrentCulture, fallbackCultureInfo);

            this.favoritesServerWatcher = new ServerWatcher(28970, 100, 1000, 2000);
            this.favoritesServerWatcher.Start();

            // Load the saved favorites servers.
            try
            {
                foreach (var favoriteServer in this.config.FavoriteServers)
                {
                    this.favoritesServerWatcher.AddServer(favoriteServer);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(
                    this.resourceManager["resErrorInvalidServerInConfig"].Value,
                    "Invalid server address loaded",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }

            // Registry
            var registry = new RegistryConfig();

            // MainWindowViewModel
            MainWindowViewModel mainWindowViewModel = new MainWindowViewModel(
                this.config,
                registry,
                new Updater.Updater(),
                this.resourceManager);

            // NewsViewModel
            NewsViewViewModel newsViewViewModel = new NewsViewViewModel(
                this.resourceManager["resNewsNotLoaded"].Value,
                this.resourceManager);

            // FavoritesViewModel
            FavoritesViewViewModel favoritesViewViewModel = new FavoritesViewViewModel(
                this.favoritesServerWatcher,
                new G2OStarter(registry),
                this.resourceManager);

            // Main window
            MainWindow window = new MainWindow(mainWindowViewModel, newsViewViewModel, favoritesViewViewModel);

            window.Show();
        }
Beispiel #22
0
 public El2SlConfig()
 {
     _registry = new RegistryConfig(@"software\el2sl\");
 }
Beispiel #23
0
 /// <summary>
 /// Removes all keys not present in the current config.  
 /// </summary>
 private void RemoveKeys(RegistryConfig config)
 {
     foreach (string valueName in config.Key.GetValueNames ())
     {
         if (!config.Contains (valueName)) {
             config.Key.DeleteValue (valueName);
         }
     }
 }
Beispiel #24
0
        /// <summary>
        /// Loads all values from the registry key.
        /// </summary>
        private void LoadKeyValues(RegistryKey key, string keyName)
        {
            RegistryConfig config = new RegistryConfig (keyName, this);
            config.Key = key;

            string[] values = key.GetValueNames ();
            foreach (string value in values)
            {
                config.Add (value, key.GetValue (value).ToString ());
            }
            this.Configs.Add (config);
        }
        /// <summary>
        /// Loads all values from the registry key.
        /// </summary>
        private void LoadKeyValues(RegistryKey key, string keyName) {
            var config = new RegistryConfig(keyName, this) { Key = key };

            var values = key.GetValueNames();
            foreach(var value in values) {
                config.Add(value, key.GetValue(value).ToString());
            }
            Configs.Add(config);
        }
Beispiel #26
0
 public HealthController(IDbConnectionFactory connectionFactory, RegistryConfig registryConfig)
 {
     _connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory));
     _registryConfig    = registryConfig ?? throw new ArgumentNullException(nameof(registryConfig));
 }