ReadFromIniFile() private method

Reads settings from an INI file on the disk and transfers them to properties.
private ReadFromIniFile ( [ path ) : void
path [
return void
示例#1
0
        public static Config Load()
        {
            // Locate all applicable config files
            var paths = Locations.GetLoadConfigPaths("0install.net", true, "injector", "global");

            // Accumulate values from all files
            var config = new Config();

            foreach (var path in paths.Reverse()) // Read least important first
            {
                config.ReadFromIniFile(path);
            }

            // Apply Windows registry policies (override existing config)
            if (WindowsUtils.IsWindowsNT)
            {
                using (var registryKey = Registry.LocalMachine.OpenSubKey(RegistryPolicyPath, writable: false))
                    if (registryKey != null)
                    {
                        config.ReadFromRegistry(registryKey);
                    }
                using (var registryKey = Registry.CurrentUser.OpenSubKey(RegistryPolicyPath, writable: false))
                    if (registryKey != null)
                    {
                        config.ReadFromRegistry(registryKey);
                    }
            }

            return(config);
        }
        public static Config Load([NotNull] string path)
        {
            Log.Debug("Loading Config from: " + path);

            var config = new Config();
            config.ReadFromIniFile(path);
            return config;
        }
        /// <summary>
        /// Loads the settings from a single INI file.
        /// </summary>
        /// <returns>The loaded <see cref="Config"/>.</returns>
        /// <exception cref="IOException">A problem occurred while reading the file.</exception>
        /// <exception cref="UnauthorizedAccessException">Read access to the file is not permitted.</exception>
        /// <exception cref="InvalidDataException">A problem occurred while deserializing the config data.</exception>
        public static Config Load(string path)
        {
            Log.Debug("Loading Config from: " + path);

            var config = new Config();

            config.ReadFromIniFile(path);
            return(config);
        }
        public static Config Load()
        {
            // Locate all applicable config files
            var paths = Locations.GetLoadConfigPaths("0install.net", true, "injector", "global");

            // Accumulate values from all files
            var config = new Config();
            foreach (var path in paths.Reverse()) // Read least important first
                config.ReadFromIniFile(path);

            // Apply Windows registry policies (override existing config)
            if (WindowsUtils.IsWindowsNT)
            {
                using (var registryKey = Registry.LocalMachine.OpenSubKey(RegistryPolicyPath, writable: false))
                    if (registryKey != null) config.ReadFromRegistry(registryKey);
                using (var registryKey = Registry.CurrentUser.OpenSubKey(RegistryPolicyPath, writable: false))
                    if (registryKey != null) config.ReadFromRegistry(registryKey);
            }

            return config;
        }