private bool TryNormalizeDependencies( IEnumerable <ITypeReference> dependencies, [NotNullWhen(true)] out IReadOnlyList <ITypeReference>?normalized) { var n = new List <ITypeReference>(); foreach (ITypeReference reference in dependencies) { if (!_typeLookup.TryNormalizeReference( reference, out ITypeReference? nr)) { normalized = null; return(false); } if (!n.Contains(nr)) { n.Add(nr); } } normalized = n; return(true); }
public bool TryPredictTypeKind(ITypeReference typeRef, out TypeKind kind) { if (_typeLookup.TryNormalizeReference(typeRef, out ITypeReference namedTypeRef) && _typeRegistry.TryGetType(namedTypeRef, out RegisteredType registeredType)) { switch (registeredType.Type) { case INamedType namedType: kind = namedType.Kind; return(true); case DirectiveType: kind = TypeKind.Directive; return(true); default: kind = default; return(false); } } namedTypeRef ??= typeRef; switch (namedTypeRef) { case ExtendedTypeReference r: if (Scalars.TryGetScalar(r.Type.Type, out _)) { kind = TypeKind.Scalar; return(true); } if (r.Type.IsSchemaType) { kind = GetTypeKindFromSchemaType(r.Type); return(true); } return(SchemaTypeResolver.TryInferSchemaTypeKind(r, out kind)); case SchemaTypeReference r: kind = GetTypeKindFromSchemaType(TypeInspector.GetType(r.Type.GetType())); return(true); default: kind = default; return(false); } }