Пример #1
0
        public override void Serialize(TextWriter writer, IEnumerable <World> worlds, SectorSerializeOptions options)
        {
            List <string> cols = new List <string> {
                "Hex",
                "Name",
                "UWP",
                "Remarks",
                "{Ix}",
                "(Ex)",
                "[Cx]",
                "N",
                "B",
                "Z",
                "PBG",
                "W",
                "A",
                "Stellar"
            };

            if (options.includeRoutes)
            {
                cols.Add("Routes");
            }

            ColumnSerializer formatter = new ColumnSerializer(cols);

            formatter.SetMinimumWidth("Name", 20);
            formatter.SetMinimumWidth("Remarks", 20);

            foreach (World world in worlds.OrderBy(world => world.SS))
            {
                List <string> row = new List <string> {
                    options.sscoords?world.SubsectorHex : world.Hex,
                           world.Name,
                           world.UWP,
                           world.Remarks,
                           world.Importance,
                           world.Economic,
                           world.Cultural,
                    DashIfEmpty(world.Nobility),
                    DashIfEmpty(world.Bases),
                    DashIfEmpty(world.Zone),
                    world.PBG,
                    world.Worlds > 0 ? world.Worlds.ToString() : "",
                    world.Allegiance,
                    world.Stellar
                };
                if (options.includeRoutes)
                {
                    row.Add(world.Routes);
                }
                formatter.AddRow(row);
            }
            formatter.Serialize(writer, options.includeHeader);
        }
Пример #2
0
 public void ColumnFormatterTest()
 {
     ColumnSerializer formatter = new ColumnSerializer(new string[] {"1", "2", "3", "4"});
     formatter.AddRow(new string[] {"a", "bb", "ccc", "dddd"} );
     formatter.AddRow(new string[] { " A ", "  BB  ", "   CCC   ", "    DDDD    " });
     formatter.AddRow(new string[] { "w", "x", "y", "z" });
     StringWriter writer = new StringWriter();
         formatter.Serialize(writer);
     Assert.AreEqual(
         "1 2  3   4   \r\n" +
         "- -- --- ----\r\n" +
         "a bb ccc dddd\r\n" +
         "A BB CCC DDDD\r\n" +
         "w x  y   z   \r\n",
         writer.ToString());
 }
Пример #3
0
        public override void Serialize(TextWriter writer, IEnumerable<World> worlds, bool includeHeader=true, bool sscoords=false)
        {
            ColumnSerializer formatter = new ColumnSerializer(new string[] {
                "Hex",
                "Name",
                "UWP",
                "Remarks",
                "{Ix}",
                "(Ex)",
                "[Cx]",
                "N",
                "B",
                "Z",
                "PBG",
                "W",
                "A",
                "Stellar"
            });

            formatter.SetMinimumWidth("Name", 20);
            formatter.SetMinimumWidth("Remarks", 20);

            foreach (World world in worlds.OrderBy(world => world.SS))
            {
                formatter.AddRow(new string[] {
                    sscoords ? world.SubsectorHex : world.Hex,
                    world.Name,
                    world.UWP,
                    world.Remarks,
                    world.Importance,
                    world.Economic,
                    world.Cultural,
                    DashIfEmpty(world.Nobility),
                    DashIfEmpty(world.Bases),
                    DashIfEmpty(world.Zone),
                    world.PBG,
                    world.Worlds > 0 ? world.Worlds.ToString() : "",
                    world.Allegiance,
                    world.Stellar
                });
            }
            formatter.Serialize(writer, includeHeader);
        }
Пример #4
0
        public override void Serialize(TextWriter writer, IEnumerable <World> worlds, bool includeHeader = true, bool sscoords = false)
        {
            ColumnSerializer formatter = new ColumnSerializer(new string[] {
                "Hex",
                "Name",
                "UWP",
                "Remarks",
                "{Ix}",
                "(Ex)",
                "[Cx]",
                "N",
                "B",
                "Z",
                "PBG",
                "W",
                "A",
                "Stellar"
            });

            formatter.SetMinimumWidth("Name", 20);
            formatter.SetMinimumWidth("Remarks", 20);

            foreach (World world in worlds.OrderBy(world => world.SS))
            {
                formatter.AddRow(new string[] {
                    sscoords?world.SubsectorHex: world.Hex,
                    world.Name,
                    world.UWP,
                    world.Remarks,
                    world.Importance,
                    world.Economic,
                    world.Cultural,
                    DashIfEmpty(world.Nobility),
                    DashIfEmpty(world.Bases),
                    DashIfEmpty(world.Zone),
                    world.PBG,
                    world.Worlds > 0 ? world.Worlds.ToString() : "",
                    world.Allegiance,
                    world.Stellar
                });
            }
            formatter.Serialize(writer, includeHeader);
        }