internal static StringBuilder AppendSuggestImmutable(this StringBuilder errorBuilder, TypeErrors errors) { var fixableTypes = errors.AllErrors.OfType<TypeErrors>() .Where(x => x.Type != errors.Type) .Select(x => x.Type) .Distinct() .ToArray(); if (!fixableTypes.Any()) { return errorBuilder; } foreach (var type in fixableTypes) { var line = type.Assembly == typeof(int).Assembly ? $"* Use an immutable type instead of {type.PrettyName()}." : $"* Make {type.PrettyName()} immutable or use an immutable type."; errorBuilder.AppendLine(line); } errorBuilder.AppendLine(" - For immutable types the following must hold:") .AppendLine(" - Must be a sealed class or a struct.") .AppendLine(" - All fields and properties must be readonly.") .AppendLine(" - All field and property types must be immutable.") .AppendLine(" - All indexers must be readonly.") .AppendLine(" - Event fields are ignored."); return errorBuilder; }
/// <summary> /// Appends the .ToString() value of the object supplied along with the default line terminator. /// </summary> public static StringBuilder AppendLine(this StringBuilder that, object value) { if (value == null) { return that.AppendLine(); } else { return that.AppendLine(value.ToString()); } }
private static void AppendTriggerable(this StringBuilder builder, Triggerable triggerable) { builder.AppendLine(" [TRIGGERABLE]"); builder.AppendFormat(" <STRING>Name:{0}\r\n", triggerable.Name); builder.AppendFormat(" <STRING>File:{0}\r\n", triggerable.File); builder.AppendLine(" [/TRIGGERABLE]"); }
public static void IndentedLines(this StringBuilder sb, String text) { string indent = new string(' ', tabs * 4); if (text.Contains("@\"")) //no splitting for verbatim strings sb.AppendLine(indent + text); else foreach (var line in text.Split('\n')) sb.AppendLine(indent + line.TrimEnd()); }
private static StringBuilder AppendWatcherChangesetPart(this StringBuilder sb, Dictionary<string, string> changesetPart, string name) { if (changesetPart.Count > 0) { sb.AppendLine(name); foreach (var item in changesetPart) { sb.AppendLine($"{item.Key} -> {item.Value}"); } } return sb; }
public static string AppendConsoleFormat(this StringBuilder builder) { builder.AppendLine("Retrieving the amount of customers and orders per city in the USA:"); builder.Append(Environment.NewLine); builder.AppendLine(string.Format("{0,-54} {1,11} {2,11}", "-".Repeat(54), "-".Repeat(11), "-".Repeat(11))); builder.AppendLine(string.Format("{0,-54} {1,11} {2,11}", "City", "Customers", "Orders")); builder.AppendLine(string.Format("{0,-54} {1,11} {2,11}", "-".Repeat(54), "-".Repeat(11), "-".Repeat(11))); return builder.ToString(); }
public static string AppendConsoleFormat(this StringBuilder builder) { builder.AppendLine("1. Created by loading the XML file, displaying first 3 elements:"); builder.Append(Environment.NewLine); builder.AppendLine(string.Format("{0,-25} {1,-25} {2,-15} {3,10}", "-".Repeat(25), "-".Repeat(25), "-".Repeat(15), "-".Repeat(10))); builder.AppendLine(string.Format("{0,-25} {1,-25} {2,-15} {3,-10}", "Title", "Author", "Published", "Price")); builder.AppendLine(string.Format("{0,-25} {1,-25} {2,-15} {3,10}", "-".Repeat(25), "-".Repeat(25), "-".Repeat(15), "-".Repeat(10))); return builder.ToString(); }
/// <summary> /// Appends a NewLine after the format string. Safe formatting for null/empty pArgs. /// </summary> /// <returns></returns> public static void AppendLineFormat(this StringBuilder pSb, string pFormat, params object[] pArgs) { if (pArgs != null && pArgs.Any()) { pSb.AppendFormat(pFormat, pArgs); pSb.AppendLine(); } else pSb.AppendLine(pFormat); }
private static void AppendSkill(this StringBuilder builder, Skill skill) { builder.AppendLine(" [SKILL]"); builder.AppendFormat(" <INTEGER64>GUID:{0}\r\n", skill.GUID); builder.AppendFormat(" <STRING>Name:{0}\r\n", skill.Name); builder.AppendFormat(" <STRING>File:{0}\r\n", skill.File); builder.AppendLine(" [/SKILL]"); }
private static StringBuilder AppendWatcherChangesetPart(this StringBuilder sb, HashSet<string> changesetPart, string name) { if (changesetPart.Count > 0) { sb.AppendLine(name); foreach (var item in changesetPart) { sb.Append(' ', 4); sb.AppendLine(item); } } return sb; }
public static bool AppendIfNotEmpty( this StringBuilder sb, string line, int index, string pre = "" ) { if( !string.IsNullOrEmpty( line ) ) { if( !string.IsNullOrEmpty( pre ) ) sb.AppendLine( pre ); sb.AppendLine( "\t" + index + ": " + line ); return true; } return false; }
public static void IndentAppendLines(this StringBuilder b, int pad, string text) { foreach (var line in text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { if (string.IsNullOrWhiteSpace(line)) b.AppendLine(); else { b.Append(' ', pad); b.AppendLine(line); } } }
/// <summary> /// Appends the format line. /// </summary> /// <param name="sb">The sb.</param> /// <param name="str">The STR.</param> /// <param name="args">The args.</param> public static void AppendLine(this StringBuilder sb, string str, params object[] args) { if (args == null || args.Length == 0) { sb.AppendLine(str); } else { sb.AppendFormat(str, args); sb.AppendLine(); } }
private static void WriteHelpPage(this StringBuilder sb, HelpPage page, int maxWidth) { sb.WriteUsage(page.ApplicationName, page.SyntaxElements, maxWidth); if (!page.Rows.Any()) return; sb.AppendLine(); sb.WriteRows(page.Rows, maxWidth); sb.AppendLine(); }
private static void AppendUserInterface(this StringBuilder builder, UserInterface userInterface) { builder.AppendLine(" [USERINTERFACE]"); builder.AppendFormat(" <STRING>Name:{0}\r\n", userInterface.Name); builder.AppendFormat(" <STRING>File:{0}\r\n", userInterface.File); builder.AppendFormat(" <INTEGER>Unknown:{0}\r\n", userInterface.Unknown); builder.AppendFormat(" <INTEGER>Unknown2:{0}\r\n", userInterface.Unknown2); builder.AppendFormat(" <SHORT>Unknown3:{0}\r\n", userInterface.Unknown3); builder.AppendFormat(" <BOOL>Unknown4:{0:X2}\r\n", userInterface.Unknown4.Value ? "True" : "False"); builder.AppendFormat(" <STRING>Unknown5:{0}\r\n", userInterface.Unknown5); builder.AppendLine(" [/USERINTERFACE]"); }
public static StringBuilder AppendLineFormat(this StringBuilder sb, string value, params object[] parameters) { if ((parameters == null) || (parameters.Length == 0)) return sb.AppendLine(value); List<object> newparams = new List<object>(); foreach (var p in parameters) if (p == null) newparams.Add(string.Empty); else newparams.Add(p); sb.AppendFormat(value, newparams.ToArray()); return sb.AppendLine(); }
/// <summary> /// Append text with separator between each section. /// </summary> public static StringBuilder AppendComment(this StringBuilder sb, string format, params object[] args) { // Add separator between each ´section if (sb.Length > 0) sb.Append(", "); return sb.AppendLine(string.Format(format, args)); }
public static StringBuilder AppendLineFormat(this StringBuilder builder, string format, params object[] args) { builder.AppendFormat(format, args); builder.AppendLine(); return builder; }
public static void AppendLine(this StringBuilder self, String format, params Object[] args) { Check.Argument(self, "self"); self.AppendFormat(format, args); self.AppendLine(); }
public static void AppendHorizontalRule(this StringBuilder stringBuilder, string sectionName = "") { string paddedSection = string.Format(" [{0}]", sectionName); const string hr = "------------------------------------------------------------------------"; string breakString = hr.Substring(0, hr.Length - paddedSection.Length) + paddedSection; stringBuilder.AppendLine(breakString); }
public static StringBuilder AppendLineIf(this StringBuilder builder, bool condition, string value) { if (condition) builder.AppendLine(value); return builder; }
public static void WriteHttpTrace(this StringBuilder stringBuilder, HttpMessageHeader messageHeader) { if (messageHeader == null) { return; } stringBuilder .AppendFormat("StartLine: {0}", messageHeader.StartLine) .AppendLine(); var headers = messageHeader.Headers.Lines.ToList(); if (headers.Count == 0) { return; } stringBuilder.AppendLine("Headers:"); foreach (var header in headers) { stringBuilder .AppendFormat(" {0}", header) .AppendLine(); } }
/// <summary> /// Appends a formated line to the given string builder. /// </summary> /// <exception cref="ArgumentNullException">The string builder can not be null.</exception> /// <exception cref="ArgumentNullException">The format can not be null.</exception> /// <param name="sb">The string builder to append the line to.</param> /// <param name="format">The <see cref="String" /> containing the format items.</param> /// <param name="arg0">The first argument.</param> /// <param name="arg1">The second argument.</param> /// <returns>Returns the string builder.</returns> public static StringBuilder AppendLineFormat( this StringBuilder sb, String format, Object arg0, Object arg1 ) { sb.ThrowIfNull( nameof( sb ) ); format.ThrowIfNull( nameof( format ) ); return sb.AppendLine( format.F( arg0, arg1 ) ); }
/// <summary> /// Appends a formatted string and the default line terminator to to this StringBuilder instance. /// </summary> /// <param name="stringBuilder"></param> /// <param name="format"></param> /// <param name="arguments"></param> /// <returns></returns> public static StringBuilder AppendLineFormat(this StringBuilder stringBuilder, string format, params object[] arguments) { var value = string.Format(format, arguments); stringBuilder.AppendLine(value); return stringBuilder; }
public static void AppendDelimiter(this StringBuilder sb, string delimiter) { if (sb.Length != 0) { sb.AppendLine(delimiter); } }
public static void AppendLineIf(this StringBuilder builder, string value, bool condition) { if (condition) { builder.AppendLine(value); } }
private static void AppendUnit(this StringBuilder builder, Unit unit) { builder.AppendLine(" [UNIT]"); builder.AppendFormat(" <INTEGER64>GUID:{0}\r\n", unit.GUID); builder.AppendFormat(" <STRING>Name:{0}\r\n", unit.Name); builder.AppendFormat(" <STRING>File:{0}\r\n", unit.File); builder.AppendFormat(" <STRING>UnitType:{0}\r\n", unit.Type); builder.AppendFormat(" <BINARY>Unknown:{0:X2}\r\n", unit.Unknown); builder.AppendFormat(" <INTEGER>Level:{0}\r\n", unit.Level); builder.AppendFormat(" <INTEGER>MinLevel:{0}\r\n", unit.MinLevel); builder.AppendFormat(" <INTEGER>MaxLevel:{0}\r\n", unit.MaxLevel); builder.AppendFormat(" <INTEGER>Rarity:{0}\r\n", unit.Rarity); builder.AppendFormat(" <INTEGER>RarityHC:{0}\r\n", unit.RarityHC); builder.AppendLine(" [/UNIT]"); }
public static void AppendLine(this StringBuilder sb, string value, int tabs) { string tabsInBuilder = String.Empty; for (int i = 0; i < tabs; i++) tabsInBuilder += "\t"; sb.AppendLine(tabsInBuilder + value); }
public static StringBuilder AppendLineIf(this StringBuilder sb, string value, bool condition) { if (condition) { sb.AppendLine(value); } return sb; }
public static StringBuilder HzEdge(this StringBuilder @this, int nColumns, Edge edge = Edge.Middle) { for (var column = 0; column <= nColumns; column++) { HzEdge(@this, column, nColumns, edge); } return @this.AppendLine(); }