private void VisitDirectives(IHasDirectives hasDirectives) { foreach (DirectiveType type in hasDirectives.Directives.Select(t => t.Type)) { Visit(type); } }
public static string DeprecationReason(this IHasDirectives syntaxNode) { DirectiveNode directive = syntaxNode.Directives .FirstOrDefault(t => t.Name.Value == _deprecated); if (directive == null) { return(null); } ArgumentNode argument = directive.Arguments .FirstOrDefault(t => t.Name.Value == _deprecationReason); if (argument == null) { return(null); } if (argument.Value is StringValueNode s) { return(s.Value); } return(null); }
public static bool TryGetSourceDirective( this IHasDirectives hasDirectives, NameString schemaName, out SourceDirective sourceDirective) { sourceDirective = hasDirectives.Directives[DirectiveNames.Source] .Select(t => t.ToObject <SourceDirective>()) .FirstOrDefault(t => schemaName.Equals(t.Schema)); return(sourceDirective != null); }
public static T?GetFirstDirective <T>( this IHasDirectives hasDirectives, string name, T?defaultValue = default) { IDirective?directive = hasDirectives.Directives[name].FirstOrDefault(); if (directive is null) { return(defaultValue); } return(directive.ToObject <T>()); }
public static bool TryGetSourceName( this IHasDirectives hasDirectives, NameString schemaName, [NotNullWhen(true)] out NameString?sourceName) { if (TryGetSourceDirective(hasDirectives, schemaName, out SourceDirective? sd)) { sourceName = sd.Name; return(true); } sourceName = null; return(false); }