/
dev-npgsql
/
npgsql
Обзор
Документация
Войти
/
dev-npgsql
/
npgsql
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
v8.0.3
src/Npgsql.GeoJSON/NpgsqlGeoJSONExtensions.cs
37 строк
2 KB
Nino Floris
Introduce resolver factories (#5374)
14 ноя 2023, 21:06
Не верифицирован
14 ноя 2023, 21:06
e8f20a0
Код
Авторство
О чём код?
using Npgsql.GeoJSON; using Npgsql.GeoJSON.Internal; using Npgsql.TypeMapping; // ReSharper disable once CheckNamespace namespace Npgsql; /// <summary> /// Extension allowing adding the GeoJSON plugin to an Npgsql type mapper. /// </summary> public static class NpgsqlGeoJSONExtensions { /// <summary> /// Sets up GeoJSON mappings for the PostGIS types. /// </summary> /// <param name="mapper">The type mapper to set up (global or connection-specific)</param> /// <param name="options">Options to use when constructing objects.</param> /// <param name="geographyAsDefault">Specifies that the geography type is used for mapping by default.</param> public static INpgsqlTypeMapper UseGeoJson(this INpgsqlTypeMapper mapper, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false) { mapper.AddTypeInfoResolverFactory(new GeoJSONTypeInfoResolverFactory(options, geographyAsDefault, crsMap: null)); return mapper; } /// <summary> /// Sets up GeoJSON mappings for the PostGIS types. /// </summary> /// <param name="mapper">The type mapper to set up (global or connection-specific)</param> /// <param name="crsMap">A custom crs map that might contain more or less entries than the default well-known crs map.</param> /// <param name="options">Options to use when constructing objects.</param> /// <param name="geographyAsDefault">Specifies that the geography type is used for mapping by default.</param> public static INpgsqlTypeMapper UseGeoJson(this INpgsqlTypeMapper mapper, CrsMap crsMap, GeoJSONOptions options = GeoJSONOptions.None, bool geographyAsDefault = false) { mapper.AddTypeInfoResolverFactory(new GeoJSONTypeInfoResolverFactory(options, geographyAsDefault, crsMap)); return mapper; } }