Exemple #1
0
        private static void ReadCsv(string content)
        {
            var lines = content.Split(CharExtensions.LineBreakChars, StringSplitOptions.RemoveEmptyEntries);

            char[] comma = { ',' };

            var entries = new List <CranMirrorEntry>();

            for (var i = 1; i < lines.Length; i++)
            {
                // Name, Country, City, URL, Host, Maintainer, OK, CountryCode, Comment
                var items = lines[i].Split(comma);
                if (items.Length >= 4)
                {
                    var e = new CranMirrorEntry()
                    {
                        Name    = items[0].Replace("\"", string.Empty),
                        Country = items[1].Replace("\"", string.Empty),
                        City    = items[2].Replace("\"", string.Empty),
                        Url     = items[3].Replace("\"", string.Empty),
                    };

                    entries.Add(e);
                }
            }

            _mirrors = entries.ToArray();
        }
Exemple #2
0
        private static void ReadCsv(string content) {
            string[] lines = content.Split(CharExtensions.LineBreakChars, StringSplitOptions.RemoveEmptyEntries);
            char[] comma = { ',' };

            List<CranMirrorEntry> entries = new List<CranMirrorEntry>();

            for (int i = 1; i < lines.Length; i++) {
                // Name, Country, City, URL, Host, Maintainer, OK, CountryCode, Comment
                string[] items = lines[i].Split(comma);
                if (items.Length >= 4) {
                    CranMirrorEntry e = new CranMirrorEntry() {
                        Name = items[0].Replace("\"", string.Empty),
                        Country = items[1].Replace("\"", string.Empty),
                        City = items[2].Replace("\"", string.Empty),
                        Url = items[3].Replace("\"", string.Empty),
                    };

                    entries.Add(e);
                }
            }

            _mirrors = entries.ToArray();
        }