コード例 #1
0
 protected override ISyntaxVisitorAction Enter(
     DirectiveNode node,
     IDocumentValidatorContext context)
 {
     if (context.Schema.TryGetDirectiveType(node.Name.Value, out DirectiveType? dt))
     {
         if (context.Path.TryPeek(out ISyntaxNode parent) &&
             TryLookupLocation(parent, out DirectiveLoc location) &&
             !dt.Locations.Contains(location))
         {
             context.Errors.Add(context.DirectiveNotValidInLocation(node));
         }
     }
     else
     {
         context.Errors.Add(context.DirectiveNotSupported(node));
     }
     return(Skip);
 }