src/Slugent.APIInfo/ConfigInfo/ConfigurationParser.cs
/// <summary>
///  Recurses the given Configuration section listing all children and further recursing down into child Sections.
/// </summary>
/// <param name="children">The configuration section to parse into</param>
/// <param name="hideValue">
///  If true, then all config values, all config sections and all children keys will have their value hidden
/// </param>
Recurses the given Configuration section listing all children and further recursing down into child Sections.
Recurses the given Configuration section listing all children and further recursing down into child Sections .
internal void RecurseChildren (IEnumerable<IConfigurationSection> children, bool hideValue = false) {
			_indentLevel++;
			bool hideChildrenOfSection = false;
			IEnumerable<IConfigurationSection> sortedChildren = children.OrderByDescending(c => c.Value).ThenBy(c => c.Key);
			foreach ( IConfigurationSection child in sortedChildren ) {
				bool hideChild = false;
				Stack<(string Value, IConfigurationProvider Provider)> childStack = GetChildrenAndOverwrites(child.Path);
				if ( hideValue || !_apiInfoBase.ShouldShowConfigKeyWord(child.Key) ) {
					if ( childStack.Count == 0 )
						_hiddenConfigSections++;
					else
						_hiddenConfigKeys++;
					hideChild = true;
				}
				if ( childStack.Count == 0 ) {
					int spaceCount = (_indentLevel + 1) * 2;
					string indentString = "";
					if ( spaceCount > 0 ) indentString = new string(' ', spaceCount);
					string rowString = indentString + "|--> " + child.Key + ":";
					if ( hideChild ) {
						rowString += "  " + "----- Section Hidden -----";
						hideChildrenOfSection = true;
					}
					_htmlStringBuilder.Append("<pre>" + rowString + "</pre>");
				}
				else {
					(string Value, IConfigurationProvider Provider) childValue = childStack.Pop();
					string configValue = hideChild ? _HIDDEN : childValue.Value;
					int spaceCount = (_indentLevel + 1) * 2;
					string indentString = "";
					if ( spaceCount > 0 ) indentString = new string(' ', spaceCount);
					string rowString = indentString + "|--: " + child.Key + ":  ";
					if ( childStack.Count == 0 ) {
						rowString += configValue + "  [ " + childValue.Provider + " ]";
						_htmlStringBuilder.Append("<pre>" + rowString + "</pre>");
					}
					else {
						_htmlStringBuilder.Append("<pre>" + rowString + "</pre>");
						int newIndent = _indentLevel + 2;
						indentString = new string(' ', newIndent * 2);
						rowString = "<pre>" + indentString + "  ** " + configValue + "  [ " + childValue.Provider + " ] </pre>";
						_htmlStringBuilder.Append(rowString);
						foreach ( (string Value, IConfigurationProvider Provider) overriddenValue in childStack ) {
							configValue = hideChild ? _HIDDEN : overriddenValue.Value;
							rowString = "<pre>" + indentString + "  -- " + configValue + "  [ " + overriddenValue.Provider + " ] </pre>";
							_htmlStringBuilder.Append(rowString);
						}
					}
				}
				RecurseChildren(child.GetChildren(), hideChildrenOfSection);
				_indentLevel--;
			}
		}
internal void RecurseChildren ( IEnumerable < IConfigurationSection > children , bool hideValue = false ) { _indentLevel ++ ; bool hideChildrenOfSection = false ; IEnumerable < IConfigurationSection > sortedChildren = children . OrderByDescending ( c => c . Value ) . ThenBy ( c => c . Key ) ; foreach ( IConfigurationSection child in sortedChildren ) { bool hideChild = false ; Stack < ( string Value , IConfigurationProvider Provider ) > childStack = GetChildrenAndOverwrites ( child . Path ) ; if ( hideValue || ! _apiInfoBase . ShouldShowConfigKeyWord ( child . Key ) ) { if ( childStack . Count == 0 ) _hiddenConfigSections ++ ; else _hiddenConfigKeys ++ ; hideChild = true ; } if ( childStack . Count == 0 ) { int spaceCount = ( _indentLevel + 1 ) * 2 ; string indentString = " " ; if ( spaceCount > 0 ) indentString = new string ( ' ' , spaceCount ) ; string rowString = indentString + " " + child . Key + " " ; if ( hideChild ) { rowString += " " + " " ; hideChildrenOfSection = true ; } _htmlStringBuilder . Append ( " " + rowString + " " ) ; } else { ( string Value , IConfigurationProvider Provider ) childValue = childStack . Pop ( ) ; string configValue = hideChild ? _HIDDEN : childValue . Value ; int spaceCount = ( _indentLevel + 1 ) * 2 ; string indentString = " " ; if ( spaceCount > 0 ) indentString = new string ( ' ' , spaceCount ) ; string rowString = indentString + " " + child . Key + " " ; if ( childStack . Count == 0 ) { rowString += configValue + " " + childValue . Provider + " " ; _htmlStringBuilder . Append ( " " + rowString + " " ) ; } else { _htmlStringBuilder . Append ( " " + rowString + " " ) ; int newIndent = _indentLevel + 2 ; indentString = new string ( ' ' , newIndent * 2 ) ; rowString = " " + indentString + " " + configValue + " " + childValue . Provider + " " ; _htmlStringBuilder . Append ( rowString ) ; foreach ( ( string Value , IConfigurationProvider Provider ) overriddenValue in childStack ) { configValue = hideChild ? _HIDDEN : overriddenValue . Value ; rowString = " " + indentString + " " + configValue + " " + overriddenValue . Provider + " " ; _htmlStringBuilder . Append ( rowString ) ; } } } RecurseChildren ( child . GetChildren ( ) , hideChildrenOfSection ) ; _indentLevel -- ; } }
Recurses the given Configuration section listing all children and further recursing down into child Sections.
Recurses the given Configuration section listing all children and further recursing down into child Sections .
// We sort the children in descending order by the value.  This way all child values are displayed first then all the sections. // Get the child as well as all providers for whom the child key was overridden // Need to go thru the config criteria we want to hide to see if the child matches.  If it does we skip it - including if it is a section match... // Is a child section // Is a child value // Write out this entry which is the current value for the key. // If there are overridden values then we list ALL the values on separate lines // Write the config Key out on line, then write all the subsequent values // Write current value // Loop thru all the over-ridden values of this key.
children
IEnumerable<IConfigurationSection>
The configuration section to parse into
The configuration section to parse into
hideValue
bool
If true, then all config values, all config sections and all children keys will have their value hidden
If true then all config values all config sections and all children keys will have their value hidden