/// <summary> /// Adds Sorting support. /// </summary> /// <param name="builder"> /// The <see cref="ISchemaBuilder"/>. /// </param> /// <param name="name"> /// The sort convention name. /// </param> /// <typeparam name="TConvention"> /// The concrete sort convention type. /// </typeparam> /// <returns> /// Returns the <see cref="ISchemaBuilder"/>. /// </returns> public static ISchemaBuilder AddSorting <TConvention>( this ISchemaBuilder builder, string?name = null) where TConvention : class, ISortConvention => builder .TryAddConvention <ISortConvention, TConvention>(name) .TryAddTypeInterceptor <SortTypeInterceptor>();
public static ISchemaBuilder TryAddConvention( this ISchemaBuilder builder, Type convention, IConvention concreteConvention, string?scope = null) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (convention is null) { throw new ArgumentNullException(nameof(convention)); } if (concreteConvention is null) { throw new ArgumentNullException(nameof(concreteConvention)); } if (!typeof(IConvention).IsAssignableFrom(convention)) { throw new ArgumentException( TypeResources.SchemaBuilder_Convention_NotSuppported, nameof(convention)); } return(builder.TryAddConvention(convention, s => concreteConvention, scope)); }
/// <summary> /// Adds Sorting support. /// </summary> /// <param name="builder"> /// The <see cref="ISchemaBuilder"/>. /// </param> /// <param name="configure"> /// Configures the convention. /// </param> /// <param name="name"> /// The sort convention name. /// </param> /// <returns> /// Returns the <see cref="ISchemaBuilder"/>. /// </returns> public static ISchemaBuilder AddSorting( this ISchemaBuilder builder, Action <ISortConventionDescriptor> configure, string?name = null) => builder .TryAddConvention <ISortConvention>(sp => new SortConvention(configure), name) .TryAddTypeInterceptor <SortTypeInterceptor>();
/// <summary> /// Adds GeoJSON compliant spatial types. /// </summary> /// <param name="builder"> /// The <see cref="ISchemaBuilder"/>. /// </param> /// <param name="conventionFactory"> /// Creates the convention for spatial types /// </param> /// <returns> /// The <see cref="ISchemaBuilder"/>. /// </returns> /// <exception cref="ArgumentNullException"> /// The <paramref name="builder"/> is <c>null</c>. /// </exception> public static ISchemaBuilder AddSpatialTypes( this ISchemaBuilder builder, Func <SpatialConvention> conventionFactory) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } return(builder .TryAddConvention <ISpatialConvention>(conventionFactory()) .TryAddTypeInterceptor <GeometryTransformerInterceptor>() .AddType <GeoJsonInterfaceType>() .AddType <GeoJsonGeometryType>() .AddType <GeoJsonPointInputType>() .AddType <GeoJsonMultiPointInputType>() .AddType <GeoJsonLineStringInputType>() .AddType <GeoJsonMultiLineStringInputType>() .AddType <GeoJsonPolygonInputType>() .AddType <GeoJsonMultiPolygonInputType>() .AddType <GeoJsonPointType>() .AddType <GeoJsonMultiPointType>() .AddType <GeoJsonLineStringType>() .AddType <GeoJsonMultiLineStringType>() .AddType <GeoJsonPolygonType>() .AddType <GeoJsonMultiPolygonType>() .AddType <GeoJsonGeometryEnumType>() .AddType <GeometryType>() .BindClrType <Coordinate, GeoJsonPositionType>()); }
public static ISchemaBuilder TryAddConvention( this ISchemaBuilder builder, Type convention, Type concreteConvention, string?scope = null) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (convention is null) { throw new ArgumentNullException(nameof(convention)); } if (concreteConvention is null) { throw new ArgumentNullException(nameof(concreteConvention)); } if (!typeof(IConvention).IsAssignableFrom(convention)) { throw new ArgumentException( TypeResources.SchemaBuilder_Convention_NotSuppported, nameof(convention)); } if (!typeof(IConvention).IsAssignableFrom(concreteConvention)) { throw new ArgumentException( TypeResources.SchemaBuilder_Convention_NotSuppported, nameof(convention)); } return(builder.TryAddConvention( convention, s => { if (s.TryGetOrCreateService(concreteConvention, out IConvention? c)) { return c; } throw Convention_UnableToCreateConvention(concreteConvention); }, scope)); }
public static ISchemaBuilder TryAddConvention( this ISchemaBuilder builder, Type convention, CreateConvention conventionFactory, string?scope = null) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (convention is null) { throw new ArgumentNullException(nameof(convention)); } return(builder.TryAddConvention(convention, conventionFactory, scope)); }
public static ISchemaBuilder TryAddConvention <TConvention, TConcreteConvention>( this ISchemaBuilder builder, string?scope = null) where TConvention : IConvention where TConcreteConvention : class, TConvention => builder.TryAddConvention(typeof(TConvention), typeof(TConcreteConvention), scope);
public static ISchemaBuilder TryAddConvention <T>( this ISchemaBuilder builder, IConvention convention, string?scope = null) where T : IConvention => builder.TryAddConvention(typeof(T), convention, scope);