コード例 #1
0
 internal void HandleStringPoolField(TzdbStreamField field)
 {
     CheckSingleField(field, stringPool);
     using (var stream = field.CreateStream())
     {
         var reader = new DateTimeZoneReader(stream, null);
         int count  = reader.ReadCount();
         stringPool = new string[count];
         for (int i = 0; i < count; i++)
         {
             stringPool[i] = reader.ReadString();
         }
     }
 }
コード例 #2
0
 internal void HandleZone1970LocationsField(TzdbStreamField field)
 {
     CheckSingleField(field, zone1970Locations);
     CheckStringPoolPresence(field);
     using (var stream = field.CreateStream())
     {
         var reader = new DateTimeZoneReader(stream, stringPool);
         var count  = reader.ReadCount();
         var array  = new TzdbZone1970Location[count];
         for (int i = 0; i < count; i++)
         {
             array[i] = TzdbZone1970Location.Read(reader);
         }
         zone1970Locations = array;
     }
 }
コード例 #3
0
 internal void HandleZoneField(TzdbStreamField field)
 {
     CheckStringPoolPresence(field);
     // Just read the ID from the zone - we don't parse the data yet.
     // (We could, but we might as well be lazy.)
     using (var stream = field.CreateStream())
     {
         var    reader = new DateTimeZoneReader(stream, stringPool);
         string id     = reader.ReadString();
         if (zoneFields.ContainsKey(id))
         {
             throw new InvalidNodaDataException("Multiple definitions for zone " + id);
         }
         zoneFields[id] = field;
     }
 }
コード例 #4
0
        internal static TzdbStreamData FromStream([NotNull] Stream stream)
        {
            Preconditions.CheckNotNull(stream, nameof(stream));
            int version = new BinaryReader(stream).ReadInt32();

            if (version != AcceptedVersion)
            {
                throw new InvalidNodaDataException("Unable to read stream with version " + version);
            }
            Builder builder = new Builder();

            foreach (var field in TzdbStreamField.ReadFields(stream))
            {
                // Only handle fields we know about
                if (FieldHandlers.TryGetValue(field.Id, out Action <Builder, TzdbStreamField> handler))
                {
                    handler(builder, field);
                }
            }
            return(new TzdbStreamData(builder));
        }
コード例 #5
0
 internal void HandleSupplementalWindowsZonesField(TzdbStreamField field)
 {
     CheckSingleField(field, windowsMapping);
     windowsMapping = field.ExtractSingleValue(WindowsZones.Read, stringPool);
 }
コード例 #6
0
 internal void HandleTzdbIdMapField(TzdbStreamField field)
 {
     CheckSingleField(field, tzdbIdMap);
     tzdbIdMap = field.ExtractSingleValue(reader => reader.ReadDictionary(), stringPool);
 }
コード例 #7
0
 internal void HandleTzdbVersionField(TzdbStreamField field)
 {
     CheckSingleField(field, tzdbVersion);
     tzdbVersion = field.ExtractSingleValue(reader => reader.ReadString(), null);
 }
コード例 #8
0
 internal void HandleTzdbIdMapField(TzdbStreamField field)
 {
     CheckSingleField(field, tzdbIdMap);
     tzdbIdMap = field.ExtractSingleValue(stringPool);
 }
コード例 #9
0
 internal void HandleTzdbVersionField(TzdbStreamField field)
 {
     CheckSingleField(field, tzdbVersion);
     tzdbVersion = "2013a";
 }