示例#1
0
            public async Task <bool> GetBestStation(string hideMinorFaction = null)
            {
                string            request = WebRequestService.EDSM_SystemStations_URL(Name);
                RequestJSONResult result  = await WebRequestService.GetWebJSONAsync(request);

                if (result.IsSuccess)
                {
                    // Setup Stations
                    if ((result.JSON != null) && result.JSON.TryGetArrayField("stations", out JSONContainer stationsJSON))
                    {
                        foreach (JSONField stationField in stationsJSON.Array)
                        {
                            if (stationField.IsObject)
                            {
                                StationInfo info = new StationInfo();
                                if (info.FromJSON(stationField.Container))
                                {
                                    if (string.IsNullOrEmpty(hideMinorFaction) || info.ControllingFaction != hideMinorFaction)
                                    {
                                        if (BestStation == null)
                                        {
                                            BestStation = info;
                                        }
                                        else if (info.IsBetterThan(BestStation))
                                        {
                                            BestStation = info;
                                        }
                                    }
                                }
                            }
                        }
                        return(true);
                    }
                }
                return(false);
            }