Contains() private method

private Contains ( string name ) : bool
name string
return bool
Example #1
0
        private void LoadLocationFiles(FileSource source, TzdbDatabase database)
        {
            if (!source.Contains(Iso3166TabFile))
            {
                return;
            }
            var iso3166 = source.ReadLines(Iso3166TabFile)
                          .Where(line => line != "" && !line.StartsWith("#"))
                          .Select(line => line.Split('\t'))
                          .ToList();

            if (source.Contains(ZoneTabFile))
            {
                var iso3166Dict = iso3166.ToDictionary(bits => bits[0], bits => bits[1]);
                database.ZoneLocations = source.ReadLines(ZoneTabFile)
                                         .Where(line => line != "" && !line.StartsWith("#"))
                                         .Select(line => TzdbZoneLocationParser.ParseLocation(line, iso3166Dict))
                                         .ToList();
            }
            if (source.Contains(Zone1970TabFile))
            {
                var iso3166Dict = iso3166.ToDictionary(bits => bits[0], bits => new TzdbZone1970Location.Country(code: bits[0], name: bits[1]));
                database.Zone1970Locations = source.ReadLines(Zone1970TabFile)
                                             .Where(line => line != "" && !line.StartsWith("#"))
                                             .Select(line => TzdbZoneLocationParser.ParseEnhancedLocation(line, iso3166Dict))
                                             .ToList();
            }
        }
 private void LoadLocationFiles(FileSource source, TzdbDatabase database)
 {
     if (!source.Contains(Iso3166TabFile))
     {
         return;
     }
     var iso3166 = source.ReadLines(Iso3166TabFile)
           .Where(line => line != "" && !line.StartsWith("#"))
           .Select(line => line.Split('\t'))
           .ToList();
     if (source.Contains(ZoneTabFile))
     {
         var iso3166Dict = iso3166.ToDictionary(bits => bits[0], bits => bits[1]);
         database.ZoneLocations = source.ReadLines(ZoneTabFile)
            .Where(line => line != "" && !line.StartsWith("#"))
            .Select(line => TzdbZoneLocationParser.ParseLocation(line, iso3166Dict))
            .ToList();
     }
     if (source.Contains(Zone1970TabFile))
     {
         var iso3166Dict = iso3166.ToDictionary(bits => bits[0], bits => new TzdbZone1970Location.Country(code: bits[0], name: bits[1]));
         database.Zone1970Locations = source.ReadLines(ZoneTabFile)
            .Where(line => line != "" && !line.StartsWith("#"))
            .Select(line => TzdbZoneLocationParser.ParseEnhancedLocation(line, iso3166Dict))
            .ToList();
     }
 }
 private void LoadZoneFiles(FileSource source, TzdbDatabase database)
 {
     var tzdbParser = new TzdbZoneInfoParser();
     foreach (var file in ZoneFiles)
     {
         if (source.Contains(file))
         {
             log?.WriteLine("Parsing file {0} . . .", file);
             using (var stream = source.Open(file))
             {
                 tzdbParser.Parse(stream, database);
             }
         }
     }
 }
Example #4
0
        private void LoadZoneFiles(FileSource source, TzdbDatabase database)
        {
            var tzdbParser = new TzdbZoneInfoParser();

            foreach (var file in ZoneFiles)
            {
                if (source.Contains(file))
                {
                    log?.WriteLine("Parsing file {0} . . .", file);
                    using (var stream = source.Open(file))
                    {
                        tzdbParser.Parse(stream, database);
                    }
                }
            }
        }
Example #5
0
        private string InferVersion(FileSource source)
        {
            if (source.Contains(Makefile))
            {
                foreach (var line in source.ReadLines(Makefile))
                {
                    if (Regex.IsMatch(line, @"VERSION=\d{4}.*"))
                    {
                        var version = line.Substring(8).Trim();
                        log?.WriteLine($"Inferred version {version} from {Makefile}");
                        return(version);
                    }
                }
            }
            var match = VersionRegex.Match(source.Origin);

            if (match.Success)
            {
                var version = match.Value;
                log?.WriteLine($"Inferred version {version} from file/directory name {source.Origin}");
                return(version);
            }
            throw new InvalidDataException("Unable to determine TZDB version from source");
        }
 private string InferVersion(FileSource source)
 {
     if (source.Contains(Makefile))
     {
         foreach (var line in source.ReadLines(Makefile))
         {
             if (line.StartsWith("VERSION="))
             {
                 var version = line.Substring(8).Trim();
                 log?.WriteLine($"Inferred version {version} from {Makefile}");
                 return version;
             }
         }
     }
     var match = VersionRegex.Match(source.Origin);
     if (match.Success)
     {
         var version = match.Value;
         log?.WriteLine($"Inferred version {version} from file/directory name {source.Origin}");
         return version;
     }
     throw new InvalidDataException("Unable to determine TZDB version from source");
 }