Documentation
Table of Contents

Method AddGuardrails

Namespace
IntentSharp.Guardrails
Assembly
IntentSharp.Guardrails.dll

AddGuardrails(IServiceCollection, IDocumentStore, params string[])

Registers the rule files store holds as the client's guardrails, with sets as the sets the client applies when a check names none. See AddGuardrails(IServiceCollection, IDocumentStore, Action<GuardrailSourceOptions>, params string[]).

public static IServiceCollection AddGuardrails(this IServiceCollection services, IDocumentStore store, params string[] sets)

Parameters

services IServiceCollection

The service collection.

store IDocumentStore

The store that holds the manifest and the rule files: the store the client uses, so register it with AddDocumentStore too.

sets string[]

The default sets; each must be loaded when the client is built.

Returns

IServiceCollection

Exceptions

ArgumentNullException

services, store or sets is null.

AddGuardrails(IServiceCollection, IDocumentStore, Action<GuardrailSourceOptions>, params string[])

Registers the rule files store holds as the client's guardrails: a DocumentGuardrailSource as the IGuardrailSource, GuardrailOptions with sets as the default sets, the YAML format, the RuleDocumentValidator and the built-in schema kind. The source and the validator know the kinds, subjects and settings declared in configure and those registered in the container (IGuardrailKind, SubjectDescriptor, SettingDescriptor), and the client's options carry the ones declared in configure and its CodeSettings as their CodeSettings. The validator compares a raised client.* limit that no running version sets with the IntentClientOptions value AddIntentSharp gives the client when the code settings do not set it. A source or options registered before this call are kept: the first registration wins.

public static IServiceCollection AddGuardrails(this IServiceCollection services, IDocumentStore store, Action<GuardrailSourceOptions> configure, params string[] sets)

Parameters

services IServiceCollection

The service collection.

store IDocumentStore

The store that holds the manifest and the rule files: the store the client uses, so register it with AddDocumentStore too.

configure Action<GuardrailSourceOptions>

Sets the source's options, such as the manifest's path or pinned hashes; runs once, now.

sets string[]

The default sets; each must be loaded when the client is built.

Returns

IServiceCollection

Remarks

No rules written as intent compile on this registration alone: call AddRuleCompilation(IServiceCollection, Action<RuleCompileOptions>?) as well (experimental, INTENTSHARP001), or register a RuleCompileHandler of your own as an IEnvironmentChangeHandler. Without either, a listed rule file that lists compile: loads with its authored rules, and the source logs a Warning once per version of that file.

Exceptions

ArgumentNullException

services, store, configure or sets is null.