コード例 #1
0
        public static List <Station> StationsFromEDDP(dynamic json)
        {
            List <Station> Stations = new List <Station>();

            if (json["stations"] != null)
            {
                foreach (dynamic station in json["stations"])
                {
                    Station Station = new Station();
                    Station.EDDBID = (long)station["id"];
                    Station.Name   = (string)station["name"];

                    Station.Allegiance       = (string)station["allegiance"];
                    Station.DistanceFromStar = (long?)station["distance_to_star"];
                    Station.HasRefuel        = (bool?)station["has_refuel"];
                    Station.HasRearm         = (bool?)station["has_rearm"];
                    Station.HasRepair        = (bool?)station["has_repair"];
                    Station.HasOutfitting    = (bool?)station["has_outfitting"];
                    Station.HasShipyard      = (bool?)station["has_shipyard"];
                    Station.HasMarket        = (bool?)station["has_market"];
                    Station.HasBlackMarket   = (bool?)station["has_blackmarket"];

                    if (((string)station["type"]) != null)
                    {
                        if (StationModels.ContainsKey((string)station["type"]))
                        {
                            Station.Model = StationModels[(string)station["type"]];
                        }
                        else
                        {
                            LogError("Unknown station model " + ((string)station["type"]));
                        }
                    }

                    if (((string)station["max_landing_pad_size"]) != null)
                    {
                        if (LandingPads.ContainsKey((string)station["max_landing_pad_size"]))
                        {
                            Station.LargestShip = LandingPads[(string)station["max_landing_pad_size"]];
                        }
                        else
                        {
                            LogError("Unknown landing pad size " + ((string)station["max_landing_pad_size"]));
                        }
                    }

                    Stations.Add(Station);
                }
            }
            return(Stations);
        }