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
servicesIServiceCollectionThe service collection.
storeIDocumentStoreThe store that holds the manifest and the rule files: the store the client uses, so register it with
AddDocumentStoretoo.setsstring[]The default sets; each must be loaded when the client is built.
Returns
- IServiceCollection
Exceptions
- ArgumentNullException
services,storeorsetsis 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
servicesIServiceCollectionThe service collection.
storeIDocumentStoreThe store that holds the manifest and the rule files: the store the client uses, so register it with
AddDocumentStoretoo.configureAction<GuardrailSourceOptions>Sets the source's options, such as the manifest's path or pinned hashes; runs once, now.
setsstring[]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,configureorsetsis null.