/// <summary> /// Returns a combined INI file formed by merging the specified INI files. /// <para> /// The result of this method is formed by merging the specified files together. /// The files are combined in order forming a chain. /// The first file in the list has the lowest priority. /// The last file in the list has the highest priority. /// </para> /// <para> /// The algorithm starts with all the sections and properties from the highest priority file. /// It then adds any sections or properties from subsequent files that are not already present. /// </para> /// <para> /// The algorithm can be controlled by providing a '[chain]' section. /// Within the 'chain' section, if 'chainNextFile' is 'false', then processing stops, /// and lower priority files are ignored. If the 'chainRemoveSections' property is specified, /// the listed sections are ignored from the files lower in the chain. /// /// </para> /// </summary> /// <param name="resources"> the INI file resources to read </param> /// <returns> the combined chained INI file </returns> /// <exception cref="UncheckedIOException"> if an IO error occurs </exception> /// <exception cref="IllegalArgumentException"> if the configuration is invalid </exception> public static IniFile combinedIniFile(IList <ResourceLocator> resources) { ArgChecker.notNull(resources, "resources"); IDictionary <string, PropertySet> sectionMap = new LinkedHashMap <string, PropertySet>(); foreach (ResourceLocator resource in resources) { IniFile file = IniFile.of(resource.CharSource); if (file.contains(CHAIN_SECTION)) { PropertySet chainSection = file.section(CHAIN_SECTION); // remove everything from lower priority files if not chaining if (chainSection.contains(CHAIN_NEXT) && bool.Parse(chainSection.value(CHAIN_NEXT)) == false) { sectionMap.Clear(); } else { // remove sections from lower priority files //JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method: sectionMap.Keys.removeAll(chainSection.valueList(CHAIN_REMOVE)); } } // add entries, replacing existing data foreach (string sectionName in file.asMap().Keys) { if (!sectionName.Equals(CHAIN_SECTION)) { //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: sectionMap.merge(sectionName, file.section(sectionName), PropertySet::overrideWith); } } } return(IniFile.of(sectionMap)); }