/// <summary> /// [Pure] このDendriteの簡易的な統計量を出力する /// </summary> public string GetInfo() { StringBuilder sb = new StringBuilder(); sb.AppendLine("Num of nodes: " + idsum.ToString()); sb.AppendLine("Num of end nodes: " + edge.ToString()); sb.AppendLine("Num of branching nodes: " + branch.ToString()); sb.AppendLine("Max real distance: " + MaxRealDistance.ToString()); sb.AppendLine("Max electrical distance: " + MaxElectricalDistance.ToString()); sb.AppendLine("Total real distance: " + TotalLength.ToString()); sb.AppendLine("Total electrical distance: " + TotalElectricalLength.ToString()); return(sb.ToString()); }
/// <summary cref="Packet.ToString(StringOutputType)" /> public override string ToString(StringOutputType outputFormat) { var buffer = new StringBuilder(); string color = ""; string colorEscape = ""; if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored) { color = Color; colorEscape = AnsiEscapeSequences.Reset; } if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored) { // build the output string buffer.AppendFormat("{0}[IPv4Packet: SourceAddress={2}, DestinationAddress={3}, HeaderLength={4}, Protocol={5}, TimeToLive={6}]{1}", color, colorEscape, SourceAddress, DestinationAddress, HeaderLength, Protocol, TimeToLive); } if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored) { // collect the properties and their value Dictionary <string, string> properties = new Dictionary <string, string>(); properties.Add("version", Version.ToString()); // FIXME: Header length output is incorrect properties.Add("header length", HeaderLength + " bytes"); string diffServices = Convert.ToString(DifferentiatedServices, 2).PadLeft(8, '0').Insert(4, " "); properties.Add("differentiated services", "0x" + DifferentiatedServices.ToString("x").PadLeft(2, '0')); properties.Add("", diffServices.Substring(0, 7) + ".. = [" + (DifferentiatedServices >> 2) + "] code point"); properties.Add(" ", ".... .." + diffServices[6] + ". = [" + diffServices[6] + "] ECN"); properties.Add(" ", ".... ..." + diffServices[7] + " = [" + diffServices[7] + "] ECE"); properties.Add("total length", TotalLength.ToString()); properties.Add("identification", "0x" + Id.ToString("x") + " (" + Id + ")"); string flags = Convert.ToString(FragmentFlags, 2).PadLeft(8, '0').Substring(5, 3); properties.Add("flags", "0x" + FragmentFlags.ToString("x").PadLeft(2, '0')); properties.Add(" ", flags[0] + ".. = [" + flags[0] + "] reserved"); properties.Add(" ", "." + flags[1] + ". = [" + flags[1] + "] don't fragment"); properties.Add(" ", ".." + flags[2] + " = [" + flags[2] + "] more fragments"); properties.Add("fragment offset", FragmentOffset.ToString()); properties.Add("time to live", TimeToLive.ToString()); properties.Add("protocol", Protocol.ToString() + " (0x" + Protocol.ToString("x") + ")"); properties.Add("header checksum", "0x" + Checksum.ToString("x") + " [" + (ValidChecksum ? "valid" : "invalid") + "]"); properties.Add("source", SourceAddress.ToString()); properties.Add("destination", DestinationAddress.ToString()); // calculate the padding needed to right-justify the property names int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys)); // build the output string buffer.AppendLine("IP: ******* IPv4 - \"Internet Protocol (Version 4)\" - offset=? length=" + TotalPacketLength); buffer.AppendLine("IP:"); foreach (var property in properties) { if (property.Key.Trim() != "") { buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " = " + property.Value); } else { buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " " + property.Value); } } buffer.AppendLine("IP:"); } // append the base class output buffer.Append(base.ToString(outputFormat)); return(buffer.ToString()); }
public void RefreshLength() { size.Text = string.Format("{0} Кб из {1} Кб", SelectedLength.ToString("#,#;0;0"), TotalLength.ToString("#,#;0;0")); }