public override string ToString() { StrBuilder builder = new StrBuilder(Name()).Append('['); AddFields(builder); return(builder.Append(']').ToString()); }
public virtual int Read() { if (_tempIndex == _eofIndex) { _tempIndex++; return(-1); } if (_tempIndex < _tempBuffer.Length()) { _currentChar = (int)_tempBuffer.CharAt(_tempIndex); } else { if (_eofIndex != -1) { return(-1); } _currentChar = NextChar(); if (_currentChar == -1) { _eofIndex = _tempIndex; } _tempBuffer.Append((char)_currentChar); } _tempIndex++; return(_currentChar); }
/// <summary>Take a Message and return formatted lines.</summary><param name="message">Message to format.</param> List <string> FormatMessage(int i) { var message = AppReporter.Report.Messages[i]; List <string> wrappedMsngr = message.Messenger.WrapToLines(ColWidths[(int)Cols.Messenger]); var prevMessageTime = (i != 0) ? AppReporter.Report.Messages[i - 1].Time : message.Time; List <string> wrappedTime; if (i == 0 || message.Time - _PrevReportedTime > TimeSpan.FromMinutes(1)) // Only display time if it differs from previous time. { wrappedTime = message.Time.ToShortTimeString().WrapToLines(ColWidths[(int)Cols.Time]); // Wrap one-line strings. Format TimeSpan then wrap resulting string. } else { wrappedTime = new List <string> { " " } }; _PrevReportedTime = message.Time; var wrappedText = message.Text.WrapToLines(ColWidths[(int)Cols.Text]); System.TimeSpan dt = (message.Time - prevMessageTime); var wrappedDT = dt.TotalSeconds.ToString("G3").WrapToLines(ColWidths[(int)Cols.Duration]); // Wrap one-line strings. Format TimeSpan then wrap resulting string. var relPath = Regex.Match(message.Path, @"Fluid.*").Value; relPath = relPath.Remove(0, 5); var wrappedPath = relPath.WrapToLines(ColWidths[(int)Cols.File]); var wrappedCaller = message.Caller.WrapToLines(ColWidths[(int)Cols.Caller]); var wrappedLine = message.Line.ToString().WrapToLines(ColWidths[(int)Cols.LineNumber]); var listOfLists = new List <List <string> >(NCols) { wrappedMsngr, wrappedTime, wrappedText, wrappedDT, wrappedPath, wrappedCaller, wrappedLine }; // Find how many lines has the element with most lines. var listOfLengths = listOfLists.Select(elm => elm.Count); int maxNLines = listOfLengths.Max(); var formattedLines = new List <string>(maxNLines); // Result is going to appear here. for (int j = 0; j < maxNLines; ++j) // Over all lines. { StrBuilder.Clear(); for (int k = 0; k < NCols; ++k) // Over all columns. { if (listOfLists[k].Count > j) // List<string> j has an element to output at line i. { StrBuilder.Append(listOfLists[k][j].PadRight(ColWidths[k] + 2)); } else { StrBuilder.Append(new string(' ', ColWidths[k] + 2)); // Add empty space } } formattedLines.Add(StrBuilder.ToString()); } return(formattedLines); }
private static string CreateLockText(VesselLockDisplay vesselLock) { StrBuilder.Length = 0; StrBuilder.Append("Loaded: ").Append(vesselLock.Loaded).AppendLine() .Append("Packed: ").Append(vesselLock.Packed).AppendLine() .Append("Immortal: ").Append(vesselLock.Immortal).AppendLine() .Append("Control: ").Append(vesselLock.ControlLockOwner).AppendLine() .Append("Update: ").Append(vesselLock.UpdateLockOwner).AppendLine() .Append("UnlUpdate: ").Append(vesselLock.UnloadedUpdateLockOwner); return(StrBuilder.ToString()); }
public string ReadLine() { if (ins == null) { return(LSystem.EMPTY); } if (ins.Available() <= 0) { return(null); } StrBuilder sbr = new StrBuilder(); int c = -1; bool keepReading = true; do { c = ins.ReadByte(); switch (c) { case N: keepReading = false; break; case R: continue; case -1: return(null); default: sbr.Append((char)c); break; } if (ins.Available() <= 0) { keepReading = false; } } while (keepReading); return(sbr.ToString()); }
protected override void AddFields(StrBuilder builder) { base.AddFields(builder); builder.Append(", x=").Append(x).Append(", y=").Append(y); }
protected virtual void AddFields(StrBuilder builder) { builder.Append("time=").Append(time).Append(", flags=") .Append(flags); }
protected internal override void AddFields(StrBuilder builder) { base.AddFields(builder); builder.Append(", keyCode=").Append(keyCode).Append(", down=").Append(down); }
protected internal override void AddFields(StrBuilder builder) { base.AddFields(builder); builder.Append(", kind=").Append(kind).Append(", id=").Append(id).Append(", pressure=").Append(pressure).Append(", size=").Append(size); }
protected internal override void AddFields(StrBuilder builder) { base.AddFields(builder); builder.Append(", id=").Append(button).Append(", down=").Append(down); }