コード例 #1
0
ファイル: MapViewModel.cs プロジェクト: brajed/mapbook-wpf
        /// <summary>
        /// Loads the locator and gets locator info
        /// If the locator is composite and has multiple locators, it gets all of them
        /// Also gets the layers that each locator is associated with, to be used for feature selection
        /// </summary>
        /// <returns>Async task</returns>
        private async Task GetInfoFromLocatorAsync()
        {
            // Load locator and get locator info
            await this.Locator.LoadAsync();

            this.LocatorInfo = this.Locator.LocatorInfo;
        }
コード例 #2
0
ファイル: ServerList.cs プロジェクト: x2rider/DayZServer
        private List <Server> GetAllSync()
        {
            string list = "";

            {
                string      serverListUrl = "https://zombies.nu/serverlist.txt";
                LocatorInfo locator       = CalculatedGameSettings.Current.Locator;
                if (locator != null && locator.ServerListUrl != null)
                {
                    serverListUrl = locator.ServerListUrl;
                }

                if (!string.IsNullOrWhiteSpace(serverListUrl))
                {
                    using (var wc = new WebClient())
                    {
                        try
                        {
                            list = wc.DownloadString(new Uri(serverListUrl));
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(list))
            {
                return(new List <Server>());               //Empty list.. Too bad.
            }
            List <Server> fullList = list
                                     .Split('\n').Select(line =>
            {
                string[] serverInfo = line.Split(';');
                var server          = new Server("", 0, "", "", 0);
                if (serverInfo.Count() > 5)
                {
                    string queryHostname = serverInfo[1];
                    ushort joinPort      = (ushort)serverInfo[2].TryInt();
                    string password      = serverInfo[3];
                    string mod           = serverInfo[4];
                    ushort queryPort     = (ushort)serverInfo[5].TryInt();

                    server = new Server(queryHostname, joinPort, password, mod, queryPort);
                }

                server.Settings = new SortedDictionary <string, string>
                {
                    { "hostname", serverInfo[0] }
                };

                return(server);
            }).ToList();

            return(fullList);
        }
コード例 #3
0
        /// <summary>
        /// Is match method belongs to locator.
        /// </summary>
        /// <param name="sublocator">Sublocator.</param>
        /// <param name="matchMethod">Match method.</param>
        /// <returns>Is match method belongs to locator.</returns>
        private static bool _IsMatchMethodBelongsToLocator(LocatorInfo sublocator, string matchMethod)
        {
            Debug.Assert(sublocator != null);
            Debug.Assert(matchMethod != null);

            bool result = sublocator.Name.Equals(matchMethod, StringComparison.OrdinalIgnoreCase) ||
                          sublocator.Title.Equals(matchMethod, StringComparison.OrdinalIgnoreCase);

            return(result);
        }