public static string ConstructTagsTable(Hashtable[] tags) { if (tags == null) { return null; } Hashtable emptyHashtable = new Hashtable { {"Name", string.Empty}, {"Value", string.Empty} }; StringBuilder resourcesTable = new StringBuilder(); if (tags.Length > 0) { int maxNameLength = Math.Max("Name".Length, tags.Where(ht => ht.ContainsKey("Name")).DefaultIfEmpty(emptyHashtable).Max(ht => ht["Name"].ToString().Length)); int maxValueLength = Math.Max("Value".Length, tags.Where(ht => ht.ContainsKey("Value")).DefaultIfEmpty(emptyHashtable).Max(ht => ht["Value"].ToString().Length)); string rowFormat = "{0, -" + maxNameLength + "} {1, -" + maxValueLength + "}\r\n"; resourcesTable.AppendLine(); resourcesTable.AppendFormat(rowFormat, "Name", "Value"); resourcesTable.AppendFormat(rowFormat, GeneralUtilities.GenerateSeparator(maxNameLength, "="), GeneralUtilities.GenerateSeparator(maxValueLength, "=")); foreach (Hashtable tag in tags) { PSTagValuePair tagValuePair = TagsConversionHelper.Create(tag); if (tagValuePair != null) { if (tagValuePair.Name.StartsWith(TagsClient.ExecludedTagPrefix)) { continue; } if (tagValuePair.Value == null) { tagValuePair.Value = string.Empty; } resourcesTable.AppendFormat(rowFormat, tagValuePair.Name, tagValuePair.Value); } } } return resourcesTable.ToString(); }