Append when the GeoFeed is retrieved and if it was generated from in memory cache
This commit is contained in:
@@ -5,10 +5,23 @@ namespace AS1024.GeoFeed.Core.Tools
|
||||
{
|
||||
public static class GeoFeedTools
|
||||
{
|
||||
public static string ToGeoFeedCsv(this List<IPGeoFeed> geoFeeds)
|
||||
/// <summary>
|
||||
/// Returns a CSV string for a given GeoFeed retreived from various sources
|
||||
/// </summary>
|
||||
/// <param name="geoFeeds">GeoFeed returned from the source of truth</param>
|
||||
/// <param name="timeStamp">If a timestamp should be appended at the header</param>
|
||||
/// <param name="isCached">If the result is cached</param>
|
||||
/// <returns></returns>
|
||||
public static string ToGeoFeedCsv(this List<IPGeoFeed> geoFeeds, bool timeStamp = false, bool isCached = false)
|
||||
{
|
||||
StringBuilder csvContent = new();
|
||||
|
||||
if (timeStamp)
|
||||
csvContent.AppendLine($"# GeoFeed generated on {DateTime.UtcNow:R}");
|
||||
|
||||
if (isCached)
|
||||
csvContent.AppendLine($"# Geofeed data is returned from local in memory cache");
|
||||
|
||||
foreach (IPGeoFeed feed in geoFeeds)
|
||||
{
|
||||
csvContent.AppendLine($"{feed.Prefix},{feed.GeolocCountry},{feed.GeolocRegion},{feed.GeolocCity},{feed.GeolocPostalCode}");
|
||||
|
||||
Reference in New Issue
Block a user