< Summary

Class:Itinero.Geo.AttributesTableExtensions
Assembly:Itinero.Geo
File(s):/home/runner/work/routing2/routing2/src/Itinero.Geo/AttributesTableExtensions.cs
Covered lines:0
Uncovered lines:15
Coverable lines:15
Total lines:39
Line coverage:0% (0 of 15)
Covered branches:0
Total branches:6
Branch coverage:0% (0 of 6)
Tag:224_14471318300

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
ToAttributes()0%20%
ToInvariantString(...)0%40%

File(s)

/home/runner/work/routing2/routing2/src/Itinero.Geo/AttributesTableExtensions.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Globalization;
 4using NetTopologySuite.Features;
 5
 6namespace Itinero.Geo;
 7
 8/// <summary>
 9/// Extension methods related to attributes tables
 10/// </summary>
 11public static class AttributesTableExtensions
 12{
 13    /// <summary>
 14    /// Converts the given attributes table to attributes for Itinero.
 15    /// </summary>
 16    /// <param name="attributesTable">The attributes table.</param>
 17    /// <returns>Attributes as string key-value pairs.</returns>
 18    public static IEnumerable<(string key, string value)> ToAttributes(this IAttributesTable attributesTable)
 019    {
 020        var names = attributesTable.GetNames();
 021        foreach (var name in names)
 022        {
 023            yield return (name, attributesTable[name].ToInvariantString());
 024        }
 025    }
 26
 27    /// <summary>
 28    /// Returns a string representing the object in a culture invariant way.
 29    /// </summary>
 30    private static string ToInvariantString(this object obj)
 031    {
 032        return obj switch
 033        {
 034            IConvertible convertible => convertible.ToString(CultureInfo.InvariantCulture),
 035            IFormattable formattable => formattable.ToString(null, CultureInfo.InvariantCulture),
 036            _ => obj.ToString()
 037        };
 038    }
 39}