public ConfigureMvcOptionsForHypermediaExtensions( HypermediaExtensionsOptions hypermediaOptions, ApplicationModel applicationModel, HypermediaQueryLocationFormatter hypermediaQueryLocationFormatter, HypermediaEntityLocationFormatter hypermediaEntityLocationFormatter, SirenHypermediaFormatter sirenHypermediaFormatter) { this.hypermediaOptions = hypermediaOptions; this.applicationModel = applicationModel; this.hypermediaQueryLocationFormatter = hypermediaQueryLocationFormatter; this.hypermediaEntityLocationFormatter = hypermediaEntityLocationFormatter; this.sirenHypermediaFormatter = sirenHypermediaFormatter; }
/// <summary> /// Adds the Hypermedia Extension Formatters. This is a infrastructure method to be used to change core behaviour of the extensions. /// For default cases consider using the convenience overloads AddHypermediaExtensions. /// By default a Siren Formatters is added and the entry assembly is crawled for Hypermedia route attributes /// </summary> public static MvcOptions AddHypermediaExtensionsOutputFormatters( this MvcOptions options, HypermediaQueryLocationFormatter hypermediaQueryLocationFormatter, HypermediaEntityLocationFormatter hypermediaEntityLocationFormatter, SirenHypermediaFormatter sirenHypermediaFormatter ) { options.OutputFormatters.Insert(0, hypermediaQueryLocationFormatter); options.OutputFormatters.Insert(0, hypermediaEntityLocationFormatter); options.OutputFormatters.Insert(0, sirenHypermediaFormatter); return(options); }
/// <summary> /// Adds the Hypermedia Extensions. /// by default a Siren Formatters is added and /// the entry assembly is crawled for Hypermedia route attributes /// </summary> /// <param name="options">The options object of the MVC component.</param> /// <param name="alternateRouteRegister">If you wish to use another RoutRegister pass it here, also if you wish another assembly to be crawled.</param> /// <param name="alternateQueryStringBuilder">Provide an alternate QueryStringBuilder used for building URL's.</param> /// <param name="hypermediaUrlConfig">Configures the URL used in Hypermedia responses.</param> /// <param name="hypermediaConverterConfiguration">Configures the creation of Hypermedia documents.</param> public static void AddHypermediaExtensions( this MvcOptions options, IRouteRegister alternateRouteRegister = null, IQueryStringBuilder alternateQueryStringBuilder = null, IHypermediaUrlConfig hypermediaUrlConfig = null, IHypermediaConverterConfiguration hypermediaConverterConfiguration = null) { var routeRegister = alternateRouteRegister ?? new AttributedRoutesRegister(); var routeResolverFactory = new RegisterRouteResolverFactory(routeRegister); var routeKeyFactory = new RouteKeyFactory(routeRegister); var queryStringBuilder = alternateQueryStringBuilder ?? new QueryStringBuilder(); var hypermediaQueryLocationFormatter = new HypermediaQueryLocationFormatter(routeResolverFactory, routeKeyFactory, queryStringBuilder, hypermediaUrlConfig); var hypermediaEntityLocationFormatter = new HypermediaEntityLocationFormatter(routeResolverFactory, routeKeyFactory, hypermediaUrlConfig); var sirenHypermediaConverterFactory = new SirenHypermediaConverterFactory(queryStringBuilder, hypermediaConverterConfiguration?.SirenConverterConfiguration); var sirenHypermediaFormatter = new SirenHypermediaFormatter(routeResolverFactory, routeKeyFactory, sirenHypermediaConverterFactory, hypermediaUrlConfig); options.OutputFormatters.Insert(0, hypermediaQueryLocationFormatter); options.OutputFormatters.Insert(0, hypermediaEntityLocationFormatter); options.OutputFormatters.Insert(0, sirenHypermediaFormatter); }