/
aprogrammer
/
reverse-proxy-ms-yarp
Обзор
Документация
Войти
/
aprogrammer
/
reverse-proxy-ms-yarp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/ReverseProxy/Transforms/RouteConfigTransformExtensions.cs
43 строки
1 KB
Kahbazi
Use is null instead of == null (#1565)
29 мар 2022, 02:51
Не верифицирован
29 мар 2022, 02:51
9bbdf5e
Код
Авторство
О чём код?
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System; using System.Collections.Generic; using Yarp.ReverseProxy.Configuration; namespace Yarp.ReverseProxy.Transforms; /// <summary> /// Extensions for adding transforms to <see cref="RouteConfig"/>. /// </summary> public static class RouteConfigTransformExtensions { /// <summary> /// Clones the <see cref="RouteConfig"/> and adds the transform. /// </summary> /// <returns>The cloned route with the new transform.</returns> public static RouteConfig WithTransform(this RouteConfig route, Action<IDictionary<string, string>> createTransform) { if (createTransform is null) { throw new ArgumentNullException(nameof(createTransform)); } List<IReadOnlyDictionary<string, string>> transforms; if (route.Transforms is null) { transforms = new List<IReadOnlyDictionary<string, string>>(); } else { transforms = new List<IReadOnlyDictionary<string, string>>(route.Transforms.Count + 1); transforms.AddRange(route.Transforms); } var transform = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); createTransform(transform); transforms.Add(transform); return route with { Transforms = transforms }; } }