private void CompleteInterfaces( ITypeRegistry typeRegistry, Action <SchemaError> reportError) { if (_interfaces != null) { foreach (InterfaceType interfaceType in _interfaces .Select(t => typeRegistry.GetType <InterfaceType>(t)) .Where(t => t != null)) { _interfaceMap[interfaceType.Name] = interfaceType; } CheckIfAllInterfaceFieldsAreImplemented(reportError); } }
private IEnumerable <InterfaceType> GetInterfaces( ITypeRegistry typeRegistry, IReadOnlyCollection <NamedTypeNode> interfaceReferences) { int i = 0; InterfaceType[] interfaces = new InterfaceType[interfaceReferences.Count]; foreach (NamedTypeNode typeNode in interfaceReferences) { interfaces[i++] = typeRegistry.GetType <InterfaceType>( typeNode.Name.Value); } return(interfaces); }
private IValueNode CreateDefaultValue(ITypeRegistry typeRegistry) { if (DefaultValue != null) { return(DefaultValue); } if (NativeDefaultValue != null) { Type nativeNamedType = TypeInspector.Default.ExtractNamedType(NativeType); IType type = typeRegistry.GetType <IType>(nativeNamedType); if (type is IInputType inputType) { return(inputType.ParseValue(NativeDefaultValue)); } } return(new NullValueNode()); }
private void CompleteTypes( ITypeRegistry typeRegistry, Action <SchemaError> reportError) { if (_types != null) { foreach (ObjectType memberType in _types .Select(t => typeRegistry.GetType <ObjectType>(t)) .Where(t => t != null)) { _typeMap[memberType.Name] = memberType; } } if (_typeMap.Count == 0) { reportError(new SchemaError( "A Union type must define one or more unique member types.", this)); } }
public static T ResolveFieldType <T>( this IField field, ITypeRegistry typeRegistry, Action <SchemaError> reportError, TypeReference typeReference) where T : IType { T type = default(T); if (typeReference != null) { type = typeRegistry.GetType <T>(typeReference); } if (ReferenceEquals(type, default(T))) { reportError(new SchemaError( $"The type `{typeReference}` of field " + $"`{field.DeclaringType.Name}.{field.Name}` could not be resolved " + "to a valid schema type.", field.DeclaringType)); } return(type); }
public static IType GetType( this ITypeRegistry typeRegistry, ITypeNode typeNode) { if (typeNode.Kind == NodeKind.NonNullType) { return(new NonNullType( GetType(typeRegistry, ((NonNullTypeNode)typeNode).Type))); } if (typeNode.Kind == NodeKind.ListType) { return(new ListType(GetType( typeRegistry, ((ListTypeNode)typeNode).Type))); } if (typeNode.Kind == NodeKind.NamedType) { return(typeRegistry.GetType <IType>( ((NamedTypeNode)typeNode).Name.Value)); } throw new NotSupportedException(); }