public static void AddDirective <T>( this IHasDirectiveDefinition directivesContainer, T directive) where T : class { if (directive is null) { throw new ArgumentNullException(nameof(directive)); } switch (directive) { case DirectiveNode node: directivesContainer.Directives.Add( new DirectiveDefinition(node)); break; case string s: AddDirective( directivesContainer, new NameString(s), Array.Empty <ArgumentNode>()); break; default: directivesContainer.Directives.Add( new DirectiveDefinition(directive)); break; } }
public static void AddDirective( this IHasDirectiveDefinition directivesContainer, NameString name, IEnumerable <ArgumentNode> arguments) { directivesContainer.Directives.Add(new DirectiveDefinition( new DirectiveNode( name.EnsureNotEmpty(nameof(name)), arguments.ToArray()))); }
public static void AddDirectives( IHasDirectiveDefinition owner, HotChocolate.Language.IHasDirectives ownerSyntax) { foreach (DirectiveNode directive in ownerSyntax.Directives) { if (!directive.IsDeprecationReason() && !directive.IsBindingDirective()) { owner.Directives.Add(new(directive)); } } }