Ejemplo n.º 1
0
        public SectorTest()
        {
            this.altOwners         = SectorAlternateOwnerHierarchyFactory.MakeList();
            this.guests            = SectorGuestFactory.MakeList();
            this.active            = SectorActiveFactory.MakeList();
            this.owners            = SectorOwnerHierarchyFactory.Make();
            this.borders           = SectorBorderFactory.MakeList();
            this.departureAirports = SectorDepartureAirportsFactory.MakeList();
            this.arrivalAirports   = SectorArrivalAirportsFactory.MakeList();

            this.model = new Sector(
                "COOL",
                5000,
                66000,
                this.owners,
                this.altOwners,
                this.active,
                this.guests,
                this.borders,
                this.arrivalAirports,
                this.departureAirports,
                DefinitionFactory.Make(),
                DocblockFactory.Make(),
                CommentFactory.Make()
                );
        }
Ejemplo n.º 2
0
 private static Faker <Sector> GetGenerator(
     string name = null,
     List <SectorActive> active = null,
     List <SectorAlternateOwnerHierarchy> alternate   = null,
     List <SectorArrivalAirports> arrivalAirports     = null,
     List <SectorDepartureAirports> departureAirports = null,
     List <SectorGuest> guests   = null,
     SectorOwnerHierarchy owners = null,
     Definition definition       = null
     )
 {
     return(new Faker <Sector>()
            .CustomInstantiator(
                f => new Sector(
                    name ?? f.Random.String2(5),
                    0,
                    66000,
                    owners ?? SectorOwnerHierarchyFactory.Make(),
                    alternate ?? SectorAlternateOwnerHierarchyFactory.MakeList(2),
                    active ?? SectorActiveFactory.MakeList(),
                    guests ?? SectorGuestFactory.MakeList(2),
                    SectorBorderFactory.MakeList(2),
                    arrivalAirports ?? SectorArrivalAirportsFactory.MakeList(),
                    departureAirports ?? SectorDepartureAirportsFactory.MakeList(),
                    definition ?? DefinitionFactory.Make(),
                    DocblockFactory.Make(),
                    CommentFactory.Make()
                    )
                ));
 }
Ejemplo n.º 3
0
 public static Sector Make(
     string name = null,
     List <SectorActive> active = null,
     List <SectorAlternateOwnerHierarchy> alternate   = null,
     List <SectorArrivalAirports> arrivalAirports     = null,
     List <SectorDepartureAirports> departureAirports = null,
     List <SectorGuest> guests   = null,
     SectorOwnerHierarchy owners = null,
     Definition definition       = null
     )
 {
     return(GetGenerator(name, active, alternate, arrivalAirports, departureAirports, guests, owners, definition).Generate());
 }
Ejemplo n.º 4
0
        public void ProcessLines(ref List <SectorData> lines, AbstractSectorDataFile file)
        {
            if (lines.Count == 0)
            {
                return;
            }

            SectorData declarationLine = lines[0];

            int minimumAltitude;
            int maximumAltitude;

            if (declarationLine.dataSegments[0] != "SECTOR")
            {
                this.errorLog.AddEvent(
                    new SyntaxError("Invalid SECTOR declaration", declarationLine)
                    );
                return;
            }

            // Check the minimum and maximum altitudes
            if (!int.TryParse(declarationLine.dataSegments[2], out minimumAltitude))
            {
                this.errorLog.AddEvent(
                    new SyntaxError("SECTOR minimum altitude must be an integer", declarationLine)
                    );
                return;
            }

            if (!int.TryParse(declarationLine.dataSegments[3], out maximumAltitude))
            {
                this.errorLog.AddEvent(
                    new SyntaxError("SECTOR maximum altitude must be an integer", declarationLine)
                    );
                return;
            }

            SectorOwnerHierarchy ownerHierarchy              = null;
            List <SectorAlternateOwnerHierarchy> altOwners   = new List <SectorAlternateOwnerHierarchy>();
            List <SectorBorder>            borders           = new List <SectorBorder>();
            List <SectorActive>            actives           = new List <SectorActive>();
            List <SectorGuest>             guests            = new List <SectorGuest>();
            List <SectorDepartureAirports> departureAirports = new List <SectorDepartureAirports>();
            List <SectorArrivalAirports>   arrivalAirports   = new List <SectorArrivalAirports>();

            for (int i = 1; i < lines.Count; i++)
            {
                try
                {
                    switch (lines[i].dataSegments[0])
                    {
                    case "OWNER":
                        ownerHierarchy = this.ParseOwnerHierarchy(lines[i]);
                        break;

                    case "ALTOWNER":
                        altOwners.Add(this.ParseAlternateOwnerHierarchy(lines[i]));
                        break;

                    case "BORDER":
                        borders.Add(this.ParseBorder(lines[i]));
                        break;

                    case "ACTIVE":
                        actives.Add(this.ParseActive(lines[i]));
                        break;

                    case "GUEST":
                        guests.Add(this.ParseGuest(lines[i]));
                        break;

                    case "DEPAPT":
                        departureAirports.Add(this.ParseDepartureAirport(lines[i]));
                        break;

                    case "ARRAPT":
                        arrivalAirports.Add(this.ParseArrivalAirport(lines[i]));
                        break;

                    default:
                        this.errorLog.AddEvent(
                            new SyntaxError("Unknown SECTOR line type", lines[i])
                            );
                        return;
                    }
                }
                catch (ArgumentException exception)
                {
                    this.errorLog.AddEvent(
                        new SyntaxError(exception.Message, lines[i])
                        );
                    return;
                }
            }

            if (ownerHierarchy == null)
            {
                this.errorLog.AddEvent(
                    new SyntaxError("Every SECTOR must have an owner", declarationLine)
                    );
                this.errorLog.AddEvent(
                    new ParserSuggestion("Have you added an OWNER declaration?")
                    );
                return;
            }

            this.sectorElements.Add(
                new Sector(
                    declarationLine.dataSegments[1],
                    minimumAltitude,
                    maximumAltitude,
                    ownerHierarchy,
                    altOwners,
                    actives,
                    guests,
                    borders,
                    arrivalAirports,
                    departureAirports,
                    declarationLine.definition,
                    declarationLine.docblock,
                    declarationLine.inlineComment
                    )
                );
        }