Class SitecoreLayoutClientBuilderExtensions

Version: 21.x

Extension methods to support configuration of layout service services.

Inheritance
System.Object
SitecoreLayoutClientBuilderExtensions
Namespace: Sitecore.LayoutService.Client.Extensions
Assembly: Sitecore.LayoutService.Client.dll
Syntax
RequestResponse
public static class SitecoreLayoutClientBuilderExtensions : Object

Methods

AddGraphQlHandler(ISitecoreLayoutClientBuilder, String, String, String, Uri)

Registers a graphQl handler to handle requests.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler> AddGraphQlHandler(this ISitecoreLayoutClientBuilder builder, string name, string siteName, string apiKey, Uri uri)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder being configured.

System.Stringname

The name used to identify the handler.

System.StringsiteName

The siteName used to identify the handler.

System.StringapiKey

The apiKey to access graphQl endpoint.

System.Uriuri

GraphQl endpoint uri.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

AddHandler<THandler>(ISitecoreLayoutClientBuilder, String, Func<IServiceProvider, THandler>)

Registers a handler of type THandler to handle requests.

Declaration
RequestResponse
public static ILayoutRequestHandlerBuilder<THandler> AddHandler<THandler>(this ISitecoreLayoutClientBuilder builder, string name, Func<IServiceProvider, THandler> factory = null)
    where THandler : ILayoutRequestHandler
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder being configured.

System.Stringname

The name used to identify the handler.

System.Func<System.IServiceProvider, THandler>factory

Optional factory to control the instantiation of the client.

Returns
TypeDescription
ILayoutRequestHandlerBuilder<THandler>

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

Type Parameters
NameDescription
THandler

The type of service to be registered for this name.

AddSystemTextJson(ISitecoreLayoutClientBuilder)

Configures System.Text.Json specific features such as input and output formatters.

Declaration
RequestResponse
public static ISitecoreLayoutClientBuilder AddSystemTextJson(this ISitecoreLayoutClientBuilder builder)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder being configured.

Returns
TypeDescription
ISitecoreLayoutClientBuilder

The ILayoutRequestHandlerBuilder<THandler> so that additional calls can be chained.

WithDefaultRequestOptions(ISitecoreLayoutClientBuilder, Action<SitecoreLayoutRequest>)

Registers the default layout service request options for all handlers.

Declaration
RequestResponse
public static ISitecoreLayoutClientBuilder WithDefaultRequestOptions(this ISitecoreLayoutClientBuilder builder, Action<SitecoreLayoutRequest> configureRequest)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilder

The ISitecoreLayoutClientBuilder being configured.

System.Action<SitecoreLayoutRequest>configureRequest

The SitecoreLayoutRequest request options configuration.

Returns

Do you have some feedback for us?

If you have suggestions for improving this article,