Organic.TabifiedStringBuilder.WriteAt C# (CSharp) Méthode

WriteAt() public méthode

Writes the value at the given index, and pads it with spaces.
public WriteAt ( int position, string content ) : void
position int
content string
Résultat void
        public void WriteAt(int position, string content)
        {
            while (Value.Length < position)
                Value += " ";
            Value += content;
        }

Usage Example

Exemple #1
0
        public static string CreateListing(List<ListEntry> output)
        {
            string listing = "";
            int maxLength = 0, maxFileLength = 0;
            foreach (var entry in output)
            {
                int length = entry.FileName.Length + 1;
                if (length > maxFileLength)
                    maxFileLength = length;
            }
            foreach (var entry in output)
            {
                int length = maxFileLength + entry.LineNumber.ToString().Length + 9;
                if (length > maxLength)
                    maxLength = length;
            }
            TabifiedStringBuilder tsb;
            foreach (var listentry in output)
            {
                tsb = new TabifiedStringBuilder();

                // FIX: TJMonk(04-20-2013) - Changing this code to use arrays, and adding support for '#' directives
                bool pass = false;

                if (listentry.ErrorCode == ErrorCode.Success)
                {
                    string[] lineStarts = { ".", "#" };
                    string[] directives = {
                        "dat", "dw", "db", "ascii","asciiz", "asciip", "asciic", "align", "fill",
                        "pad", "incbin", "reserve", "incpack", "relocate"
                    };

                    string toCheck = listentry.Code.ToLower();
                    bool checkLineStart = false;
                    foreach (var s in lineStarts)
                    {
                        if (toCheck.StartsWith(s))
                        {
                            checkLineStart = true;
                            toCheck = toCheck.Substring(s.Length);
                            break;
                        }
                    }

                    if (checkLineStart)
                    {
                        foreach (var s in directives)
                        {
                            if (toCheck.StartsWith(s))
                            {
                                pass = true;
                                break;
                            }
                        }
                    }
                }

                if (pass)
                {
                    // ENDFIX: TJMonk(04-20-2013)
                    // Write code line
                    tsb = new TabifiedStringBuilder();
                    tsb.WriteAt(0, listentry.FileName);
                    tsb.WriteAt(maxFileLength, "(line " + listentry.LineNumber + "): ");
                    if (listentry.Listed)
                        tsb.WriteAt(maxLength, "[0x" + LongHex(listentry.Address) + "] ");
                    else
                        tsb.WriteAt(maxLength, "[NOLIST] ");
                    tsb.WriteAt(maxLength + 25, listentry.Code);
                    listing += tsb.Value + Environment.NewLine;
                    // Write data
                    if (listentry.Output != null)
                    {
                        for (int i = 0; i < listentry.Output.Length; i += 8)
                        {
                            tsb = new TabifiedStringBuilder();
                            tsb.WriteAt(0, listentry.FileName);
                            tsb.WriteAt(maxFileLength, "(line " + listentry.LineNumber + "): ");
                            if (listentry.Listed)
                                tsb.WriteAt(maxLength, "[0x" + LongHex((ushort)(listentry.Address + i)) + "] ");
                            else
                                tsb.WriteAt(maxLength, "[NOLIST] ");
                            string data = "";
                            for (int j = 0; j < 8 && i + j < listentry.Output.Length; j++)
                            {
                                data += LongHex(listentry.Output[i + j]) + " ";
                            }
                            tsb.WriteAt(maxLength + 30, data.Remove(data.Length - 1));
                            listing += tsb.Value + Environment.NewLine;
                        }
                    }
                }
                else
                {
                    if (listentry.ErrorCode != ErrorCode.Success)
                    {
                        tsb = new TabifiedStringBuilder();
                        tsb.WriteAt(0, listentry.FileName);
                        tsb.WriteAt(maxFileLength, "(line " + listentry.LineNumber + "): ");
                        if (listentry.Listed)
                            tsb.WriteAt(maxLength, "[0x" + LongHex(listentry.Address) + "] ");
                        else
                            tsb.WriteAt(maxLength, "[NOLIST] ");
                        tsb.WriteAt(maxLength + 8, "ERROR: " + ListEntry.GetFriendlyErrorMessage(listentry.ErrorCode));
                        listing += tsb.Value + Environment.NewLine;
                    }
                    if (listentry.WarningCode != WarningCode.None)
                    {
                        tsb = new TabifiedStringBuilder();
                        tsb.WriteAt(0, listentry.FileName);
                        tsb.WriteAt(maxFileLength, "(line " + listentry.LineNumber + "): ");
                        if (listentry.Listed)
                            tsb.WriteAt(maxLength, "[0x" + LongHex(listentry.Address) + "] ");
                        else
                            tsb.WriteAt(maxLength, "[NOLIST] ");
                        tsb.WriteAt(maxLength + 8, "WARNING: " + ListEntry.GetFriendlyWarningMessage(listentry.WarningCode));
                        listing += tsb.Value + Environment.NewLine;
                    }
                    tsb = new TabifiedStringBuilder();
                    tsb.WriteAt(0, listentry.FileName);
                    tsb.WriteAt(maxFileLength, "(line " + listentry.LineNumber + "): ");
                    if (listentry.Listed)
                        tsb.WriteAt(maxLength, "[0x" + LongHex(listentry.Address) + "] ");
                    else
                        tsb.WriteAt(maxLength, "[NOLIST] ");
                    if (listentry.Output != null)
                    {
                        if (listentry.Output.Length > 0)
                        {
                            tsb.WriteAt(maxLength + 8, DumpArray(listentry.Output));
                            tsb.WriteAt(maxLength + 25, listentry.Code);
                        }
                    }
                    else
                        tsb.WriteAt(maxLength + 23, listentry.Code);
                    listing += tsb.Value + Environment.NewLine;
                }
            }
            return listing;
        }
All Usage Examples Of Organic.TabifiedStringBuilder::WriteAt