Esempio n. 1
0
        private bool RegisterTypes()
        {
            var typeRegistrar = new TypeRegistrar(
                _services,
                _descriptorContext,
                _initialTypes,
                ClrTypes,
                _contextData);

            if (typeRegistrar.Complete())
            {
                foreach (InitializationContext context in
                         typeRegistrar.InitializationContexts)
                {
                    foreach (FieldReference reference in context.Resolvers.Keys)
                    {
                        if (!_res.ContainsKey(reference))
                        {
                            _res[reference] = context.Resolvers[reference];
                        }
                    }
                    _initContexts.Add(context);
                }

                foreach (ITypeReference key in typeRegistrar.Registerd.Keys)
                {
                    _types[key] = typeRegistrar.Registerd[key];
                }

                return(true);
            }

            _errors.AddRange(typeRegistrar.Errors);
            return(false);
        }
Esempio n. 2
0
        public TypeDiscoverer(
            ISet <ITypeReference> initialTypes,
            IDictionary <IClrTypeReference, ITypeReference> clrTypeReferences,
            IDescriptorContext descriptorContext,
            IDictionary <string, object> contextData,
            ITypeInitializationInterceptor interceptor,
            IServiceProvider services)
        {
            _unregistered.AddRange(IntrospectionTypes.All);
            _unregistered.AddRange(Directives.All);
            _unregistered.AddRange(clrTypeReferences.Values);
            _unregistered.AddRange(initialTypes);

            _clrTypeReferences = clrTypeReferences;

            _typeRegistrar = new TypeRegistrar(
                _registeredTypes,
                clrTypeReferences,
                descriptorContext,
                contextData,
                interceptor,
                services);

            _handlers = new ITypeRegistrarHandler[]
            {
                new SchemaTypeReferenceHandler(),
                new ClrTypeReferenceHandler(),
                new SyntaxTypeReferenceHandler()
            };
        }
Esempio n. 3
0
        private void RegisterTypes(ISchemaContext context, string queryTypeName)
        {
            var typeRegistrar = new TypeRegistrar(
                context.Types.GetTypes());

            typeRegistrar.RegisterTypes(context, queryTypeName);
            _errors.AddRange(typeRegistrar.Errors);
        }
Esempio n. 4
0
        private void RegisterTypes(ISchemaContext context)
        {
            TypeRegistrar typeRegistrar = new TypeRegistrar(
                context.Types.GetTypes());

            typeRegistrar.RegisterTypes(context);
            _errors.AddRange(typeRegistrar.Errors);
        }
Esempio n. 5
0
        public TypeDiscoverer(
            IDescriptorContext context,
            TypeRegistry typeRegistry,
            TypeLookup typeLookup,
            IEnumerable <ITypeReference> initialTypes,
            ITypeInterceptor interceptor,
            bool includeSystemTypes = true)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (typeRegistry is null)
            {
                throw new ArgumentNullException(nameof(typeRegistry));
            }

            if (typeLookup is null)
            {
                throw new ArgumentNullException(nameof(typeLookup));
            }

            if (initialTypes is null)
            {
                throw new ArgumentNullException(nameof(initialTypes));
            }

            if (interceptor is null)
            {
                throw new ArgumentNullException(nameof(interceptor));
            }

            _typeRegistry = typeRegistry;

            if (includeSystemTypes)
            {
                _unregistered.AddRange(
                    IntrospectionTypes.CreateReferences(context.TypeInspector));
                _unregistered.AddRange(
                    Directives.CreateReferences(context.TypeInspector));
            }

            _unregistered.AddRange(typeRegistry.GetTypeRefs());
            _unregistered.AddRange(initialTypes.Distinct());

            _typeRegistrar = new TypeRegistrar(context, typeRegistry, typeLookup, interceptor);

            _handlers = new ITypeRegistrarHandler[]
            {
                new SchemaTypeReferenceHandler(),
                new ExtendedTypeReferenceHandler(context.TypeInspector),
                new SyntaxTypeReferenceHandler(context.TypeInspector)
            };

            _typeInspector = context.TypeInspector;
        }