/// <summary>
 ///   Parses the file defined by the given <see cref="FileInfo" />.
 /// </summary>
 /// <remarks>
 ///   Currently this compiler only handles files in the Olson (TZDB) zone info format.
 /// </remarks>
 /// <param name="file">The file to parse.</param>
 /// <param name="database">The <see cref="TzdbDatabase" /> where the parsed data is placed.</param>
 internal void ParseFile(FileInfo file, TzdbDatabase database)
 {
     using (FileStream stream = file.OpenRead())
     {
         tzdbParser.Parse(stream, database);
     }
 }
예제 #2
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);
             }
         }
     }
 }
예제 #3
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);
                    }
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Helper method to create a database and call Parse with the given text.
 /// </summary>
 private TzdbDatabase ParseText(string line)
 {
     var parser = new TzdbZoneInfoParser();
     var database = new TzdbDatabase("version");
     parser.Parse(new StringReader(line), database);
     return database;
 }
예제 #5
0
 private static List<DateTimeZone> LoadTzSources(IEnumerable<byte[]> sources)
 {
     var parser = new TzdbZoneInfoParser();
     var database = new TzdbDatabase(version: "ignored");
     foreach (var source in sources)
     {
         parser.Parse(new MemoryStream(source), database);
     }
     return database.GenerateDateTimeZones()
         .Concat(database.Aliases.Keys.Select(database.GenerateDateTimeZone))
         .ToList();            
 }