public DateTimeFormatCollection(string file) { using (var reader = FileSystemUtils.GetStreamReaderForFileOrResource(file)) { if (reader == null) { return; } while (!reader.EndOfStream) { var entry = reader.ReadLine(); if (string.IsNullOrEmpty(entry) || entry[0] == '#') { continue; } Add(entry); } } }
private static void InitMapping() { m_NeedsInit = false; foreach (var wintz in MappedSystemTimeZone()) { m_Mapping.AddIfNew(wintz.Key.Id, wintz.Value); m_Mapping.AddIfNew(wintz.Key.DisplayName, wintz.Value); } using (var reader = FileSystemUtils.GetStreamReaderForFileOrResource("TZMapping.txt")) { if (reader == null) { return; } while (!reader.EndOfStream) { var entry = reader.ReadLine(); if (string.IsNullOrEmpty(entry) || entry[0] == '#') { continue; } var tab = entry.IndexOf('\t'); if (tab <= 0) { continue; } var timeZoneID = entry.Substring(tab + 1); if (DateTimeZoneProviders.Tzdb.Ids.Contains(timeZoneID)) { m_Mapping.AddIfNew(entry.Substring(0, tab), timeZoneID); } else { Debug.WriteLine("Mapping target not found: " + entry); } } } }