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(); } } }
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; } }
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; } }
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)); }
internal void HandleSupplementalWindowsZonesField(TzdbStreamField field) { CheckSingleField(field, windowsMapping); windowsMapping = field.ExtractSingleValue(WindowsZones.Read, stringPool); }
internal void HandleTzdbIdMapField(TzdbStreamField field) { CheckSingleField(field, tzdbIdMap); tzdbIdMap = field.ExtractSingleValue(reader => reader.ReadDictionary(), stringPool); }
internal void HandleTzdbVersionField(TzdbStreamField field) { CheckSingleField(field, tzdbVersion); tzdbVersion = field.ExtractSingleValue(reader => reader.ReadString(), null); }
internal void HandleTzdbIdMapField(TzdbStreamField field) { CheckSingleField(field, tzdbIdMap); tzdbIdMap = field.ExtractSingleValue(stringPool); }
internal void HandleTzdbVersionField(TzdbStreamField field) { CheckSingleField(field, tzdbVersion); tzdbVersion = "2013a"; }