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
public static class SitecoreLayoutClientBuilderExtensions : Object

Methods

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

Registers a graphQl handler to handle requests.

Declaration
public static ILayoutRequestHandlerBuilder<GraphQlLayoutServiceHandler> AddGraphQlHandler(this ISitecoreLayoutClientBuilder builder, string name, string siteName, string apiKey, Uri uri)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder being configured.
System.StringnameThe name used to identify the handler.
System.StringsiteNameThe siteName used to identify the handler.
System.StringapiKeyThe apiKey to access graphQl endpoint.
System.UriuriGraphQl endpoint uri.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

<

GraphQlLayoutServiceHandler

>
The ILayoutRequestHandlerBuilder so that additional calls can be chained.

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

Registers a handler of type THandler to handle requests.

Declaration
public static ILayoutRequestHandlerBuilder<THandler> AddHandler<THandler>(this ISitecoreLayoutClientBuilder builder, string name, Func<IServiceProvider, THandler> factory = null)
    where THandler : ILayoutRequestHandler
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder being configured.
System.StringnameThe name used to identify the handler.
System.Func

<

System.IServiceProvider

, THandler>
factoryOptional factory to control the instantiation of the client.
Returns
TypeDescription
ILayoutRequestHandlerBuilder

The ILayoutRequestHandlerBuilder so that additional calls can be chained.
Type Parameters
NameDescription
THandlerThe type of service to be registered for this name.

AddSystemTextJson(ISitecoreLayoutClientBuilder)

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

Declaration
public static ISitecoreLayoutClientBuilder AddSystemTextJson(this ISitecoreLayoutClientBuilder builder)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder being configured.
Returns
TypeDescription
ISitecoreLayoutClientBuilderThe ILayoutRequestHandlerBuilder so that additional calls can be chained.

WithDefaultRequestOptions(ISitecoreLayoutClientBuilder, Action)

Registers the default layout service request options for all handlers.

Declaration
public static ISitecoreLayoutClientBuilder WithDefaultRequestOptions(this ISitecoreLayoutClientBuilder builder, Action<SitecoreLayoutRequest> configureRequest)
Parameters
TypeNameDescription
ISitecoreLayoutClientBuilderbuilderThe ISitecoreLayoutClientBuilder being configured.
System.Action

<

SitecoreLayoutRequest

>
configureRequestThe SitecoreLayoutRequest request options configuration.
Returns
TypeDescription
ISitecoreLayoutClientBuilderThe configured ISitecoreLayoutClientBuilder.
If you have suggestions for improving this article, let us know!