Esempio n. 1
0
        private bool TryInferTypes()
        {
            bool inferred = false;

            foreach (IClrTypeReference unresolvedType in _typeRegistrar.GetUnresolved())
            {
                if (Scalars.TryGetScalar(unresolvedType.Type, out IClrTypeReference 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);
        }
Esempio n. 2
0
        private bool TryInferTypes()
        {
            var inferred = false;

            foreach (ExtendedTypeReference unresolvedType in
                     _typeRegistrar.GetUnresolved().OfType <ExtendedTypeReference>())
            {
                if (Scalars.TryGetScalar(unresolvedType.Type.Type, out Type? scalarType))
                {
                    inferred = true;

                    ExtendedTypeReference typeReference = _typeInspector.GetTypeRef(scalarType);
                    _unregistered.Add(typeReference);
                    _typeRegistrar.MarkResolved(unresolvedType);
                    _typeRegistry.TryRegister(unresolvedType, typeReference);
                }
                else if (SchemaTypeResolver.TryInferSchemaType(
                             _typeInspector, unresolvedType, out ExtendedTypeReference schemaType))
                {
                    inferred = true;

                    _unregistered.Add(schemaType);
                    _typeRegistrar.MarkResolved(unresolvedType);
                }
            }

            return(inferred);
        }