public TypeInitializer(
            IServiceProvider services,
            IDescriptorContext descriptorContext,
            IEnumerable <ITypeReference> initialTypes,
            IEnumerable <Type> externalResolverTypes,
            IDictionary <string, object> contextData,
            ITypeInitializationInterceptor interceptor,
            IsOfTypeFallback isOfType,
            Func <TypeSystemObjectBase, bool> isQueryType)
        {
            if (initialTypes == null)
            {
                throw new ArgumentNullException(nameof(initialTypes));
            }

            if (externalResolverTypes == null)
            {
                throw new ArgumentNullException(nameof(externalResolverTypes));
            }

            _services = services
                        ?? throw new ArgumentNullException(nameof(services));
            _descriptorContext = descriptorContext
                                 ?? throw new ArgumentNullException(nameof(descriptorContext));
            _contextData = contextData
                           ?? throw new ArgumentNullException(nameof(contextData));
            _interceptor = interceptor
                           ?? throw new ArgumentNullException(nameof(interceptor));
            _isOfType    = isOfType;
            _isQueryType = isQueryType
                           ?? throw new ArgumentNullException(nameof(isQueryType));
            _externalResolverTypes = externalResolverTypes.ToList();
            _initialTypes          = initialTypes.ToList();
        }
Beispiel #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()
            };
        }
Beispiel #3
0
        public InitializationContext(
            ITypeSystemObject type,
            IServiceProvider services,
            IDescriptorContext descriptorContext,
            IDictionary <string, object> contextData,
            ITypeInitializationInterceptor interceptor)
        {
            Type = type
                   ?? throw new ArgumentNullException(nameof(type));
            Services = services
                       ?? throw new ArgumentNullException(nameof(services));
            DescriptorContext = descriptorContext
                                ?? throw new ArgumentNullException(nameof(descriptorContext));
            ContextData = contextData
                          ?? throw new ArgumentNullException(nameof(contextData));
            Interceptor = interceptor
                          ?? throw new ArgumentNullException(nameof(interceptor));
            IsDirective = type is DirectiveType;

            if (type is INamedType nt)
            {
                IsType = true;
                IsIntrospectionType = nt.IsIntrospectionType();
            }

            InternalName = "Type_" + Guid.NewGuid().ToString("N");
        }
        public ISchemaBuilder AddTypeInterceptor(ITypeInitializationInterceptor interceptor)
        {
            if (interceptor is null)
            {
                throw new ArgumentNullException(nameof(interceptor));
            }

            _interceptors.Add(interceptor);
            return(this);
        }
Beispiel #5
0
 public TypeRegistrar(
     IDictionary <ITypeReference, RegisteredType> registeredTypes,
     IDictionary <IClrTypeReference, ITypeReference> clrTypeReferences,
     IDescriptorContext descriptorContext,
     IDictionary <string, object> contextData,
     ITypeInitializationInterceptor interceptor,
     IServiceProvider services)
 {
     _registered              = registeredTypes;
     _clrTypeReferences       = clrTypeReferences;
     _descriptorContext       = descriptorContext;
     _contextData             = contextData;
     _interceptor             = interceptor;
     _serviceFactory.Services = services;
 }
Beispiel #6
0
        public static IRequestExecutorBuilder TryAddTypeInterceptor(
            this IRequestExecutorBuilder builder,
            ITypeInitializationInterceptor typeInterceptor)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

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

            return(builder.ConfigureSchema(b => b.TryAddTypeInterceptor(typeInterceptor)));
        }
Beispiel #7
0
 public TypeInitializer(
     IServiceProvider services,
     IDescriptorContext descriptorContext,
     IDictionary <string, object> contextData,
     IEnumerable <ITypeReference> initialTypes,
     IEnumerable <Type> externalResolverTypes,
     ITypeInitializationInterceptor interceptor,
     IsOfTypeFallback isOfType,
     Func <TypeSystemObjectBase, bool> isQueryType)
 {
     _services              = services;
     _descriptorContext     = descriptorContext;
     _contextData           = contextData;
     _initialTypes          = initialTypes.ToList();
     _externalResolverTypes = externalResolverTypes.ToList();
     _interceptor           = interceptor;
     _isOfType              = isOfType;
     _isQueryType           = isQueryType;
 }
Beispiel #8
0
        public TypeRegistrar(
            IServiceProvider services,
            IDescriptorContext descriptorContext,
            IEnumerable <ITypeReference> initialTypes,
            IDictionary <ITypeReference, ITypeReference> clrTypes,
            IDictionary <string, object> contextData,
            ITypeInitializationInterceptor interceptor)
        {
            if (services is null)
            {
                throw new ArgumentNullException(nameof(services));
            }

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

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

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

            _descriptorContext = descriptorContext
                                 ?? throw new ArgumentNullException(nameof(descriptorContext));
            ClrTypes = clrTypes
                       ?? throw new ArgumentNullException(nameof(clrTypes));

            _unregistered.AddRange(IntrospectionTypes.All);
            _unregistered.AddRange(Directives.All);
            _unregistered.AddRange(initialTypes);
            _serviceFactory.Services = services;
            _contextData             = contextData;
            _interceptor             = interceptor;
        }