public static ITransformationMap <TCollection, TElement> LinkElements <TCollection, TElement>(
            [NotNull] this IElementTransformationMap <TCollection, TElement> elementTransformationMap,
            [NotNull] Uri relation,
            [NotNull] Func <TElement, ILinkData> selector)
            where TCollection : IReadOnlyCollection <TElement>
        {
            if (elementTransformationMap is null)
            {
                throw new ArgumentNullException(nameof(elementTransformationMap));
            }
            if (relation is null)
            {
                throw new ArgumentNullException(nameof(relation));
            }
            if (!relation.IsAbsoluteUri)
            {
                throw new ArgumentException(RelativeRelationUri, nameof(relation));
            }
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            return(elementTransformationMap.LinkElements(relation.AbsoluteUri, selector));
        }
        public static ITransformationMap <TCollection, TElement> LinkElements <TCollection, TElement>(
            [NotNull] this IElementTransformationMap <TCollection, TElement> elementTransformationMap,
            [NotNull] string relation,
            [NotNull] Func <TElement, Uri> selector)
            where TCollection : IReadOnlyCollection <TElement>
        {
            if (elementTransformationMap is null)
            {
                throw new ArgumentNullException(nameof(elementTransformationMap));
            }
            if (relation is null)
            {
                throw new ArgumentNullException(nameof(relation));
            }
            if (selector is null)
            {
                throw new ArgumentNullException(nameof(selector));
            }

            return(elementTransformationMap.LinkElements(relation, t => selector(t)?.Pipe(Const)));
        }
Ejemplo n.º 3
0
 /// <summary>Creates links to the elements for the given collection type.</summary>
 /// <typeparam name="TCollection">The collection type being transformed.</typeparam>
 /// <typeparam name="TElement">The element type of <typeparamref name="TCollection"/>.</typeparam>
 /// <param name="elementTransformationMap">The element transformation map to which to add the link.</param>
 /// <param name="relation">The name of the link relation to establish.</param>
 /// <param name="selector">
 /// A function that creates a <see cref="Uri"/>
 /// from a value of type <typeparamref name="TElement"/>.
 /// </param>
 /// <returns>The modified transformation map.</returns>
 public static ITransformationMap <TCollection, TElement> LinkElements <TCollection, TElement>(
     this IElementTransformationMap <TCollection, TElement> elementTransformationMap,
     string relation,
     Func <TElement, Uri> selector)
     where TCollection : IReadOnlyCollection <TElement> => elementTransformationMap is null
         ? throw new ArgumentNullException(nameof(elementTransformationMap))