Ejemplo n.º 1
0
            // namespace object not constructable.
            internal static string Format(string s, int width, TFileDumper.Align align)
            {
                if (s.Length >= width)
                {
                    return(s);
                }
                int room = width - s.Length;

                TFileDumper.Align alignAdjusted = align;
                if (room == 1)
                {
                    alignAdjusted = TFileDumper.Align.Left;
                }
                if (alignAdjusted == TFileDumper.Align.Left)
                {
                    return(s + string.Format("%" + room + "s", string.Empty));
                }
                if (alignAdjusted == TFileDumper.Align.Right)
                {
                    return(string.Format("%" + room + "s", string.Empty) + s);
                }
                if (alignAdjusted == TFileDumper.Align.Center)
                {
                    int half = room / 2;
                    return(string.Format("%" + half + "s", string.Empty) + s + string.Format("%" + (room
                                                                                                    - half) + "s", string.Empty));
                }
                throw new ArgumentException("Unsupported alignment");
            }
Ejemplo n.º 2
0
 internal static string Format(long l, int width, TFileDumper.Align align)
 {
     if (align == TFileDumper.Align.ZeroPadded)
     {
         return(string.Format("%0" + width + "d", l));
     }
     return(Format(System.Convert.ToString(l), width, align));
 }