private bool InferSchemaTypesFromUnresolved() { bool resolved = false; foreach (IClrTypeReference unresolvedType in Unresolved.ToList()) { if (Scalars.TryGetScalar(unresolvedType.Type, out IClrTypeReference schemaType)) { resolved = true; _unregistered.Add(schemaType); Unresolved.Remove(unresolvedType); if (!ClrTypes.ContainsKey(unresolvedType)) { ClrTypes.Add(unresolvedType, schemaType); } } else if (SchemaTypeResolver.TryInferSchemaType(unresolvedType, out schemaType)) { resolved = true; _unregistered.Add(schemaType); Unresolved.Remove(unresolvedType); } } return(resolved); }
private bool TryInferTypes() { var inferred = false; foreach (ClrTypeReference unresolvedType in _typeRegistrar.GetUnresolved().OfType <ClrTypeReference>()) { if (Scalars.TryGetScalar(unresolvedType.Type, out ClrTypeReference schemaType)) { inferred = true; _unregistered.Add(schemaType); _typeRegistrar.MarkResolved(unresolvedType); if (!_clrTypeReferences.ContainsKey(unresolvedType)) { _clrTypeReferences.Add(unresolvedType, schemaType); } } else if (SchemaTypeResolver.TryInferSchemaType(unresolvedType, out schemaType)) { inferred = true; _unregistered.Add(schemaType); _typeRegistrar.MarkResolved(unresolvedType); } } return(inferred); }
public void InferEnumType(TypeContext context) { // arrange ExtendedTypeReference typeReference = TypeReference.Create(TypeOf <Foo>(), context); // act var success = SchemaTypeResolver.TryInferSchemaType( _typeInspector, typeReference, out ExtendedTypeReference schemaType); // assert Assert.True(success); Assert.Equal(TypeContext.None, schemaType.Context); Assert.Equal(typeof(EnumType <Foo>), schemaType.Type.Source); }
public void InferInputObjectType() { // arrange ExtendedTypeReference typeReference = TypeReference.Create(TypeOf <Bar>(), TypeContext.Input); // act var success = SchemaTypeResolver.TryInferSchemaType( _typeInspector, typeReference, out ExtendedTypeReference schemaType); // assert Assert.True(success); Assert.Equal(TypeContext.Input, schemaType.Context); Assert.Equal(typeof(InputObjectType <Bar>), schemaType.Type.Source); }