protected override void OnRegisterDependencies(
            ITypeInitializationContext context)
        {
            base.OnRegisterDependencies(context);

            if (_member != null)
            {
                context.RegisterResolver(Name, _member);
            }
        }
Beispiel #2
0
 protected override void OnCompleteType(
     ITypeInitializationContext context)
 {
     if (!Values.Any())
     {
         // TODO : Resources
         context.ReportError(new SchemaError(
                                 $"The enum type `{Name}` has no values."));
     }
 }
Beispiel #3
0
 private void ValidateFieldsRequirement(
     ITypeInitializationContext context)
 {
     if (Fields.Count == 0)
     {
         context.ReportError(new SchemaError(
                                 $"Interface `{Name}` has no fields declared.",
                                 this));
     }
 }
Beispiel #4
0
        protected override void OnRegisterDependencies(
            ITypeInitializationContext context)
        {
            base.OnRegisterDependencies(context);

            foreach (TypeReference typeReference in _types)
            {
                context.RegisterType(typeReference);
            }
        }
Beispiel #5
0
        protected override void OnCompleteType(ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            foreach (INeedsInitialization argument in Arguments
                     .Cast <INeedsInitialization>())
            {
                argument.CompleteType(context);
            }
        }
Beispiel #6
0
        protected override void OnRegisterDependencies(ITypeInitializationContext context)
        {
            base.OnRegisterDependencies(context);

            foreach (INeedsInitialization argument in Arguments
                     .Cast <INeedsInitialization>())
            {
                argument.RegisterDependencies(context);
            }
        }
Beispiel #7
0
        private void CompleteExecutableDirectives(
            ITypeInitializationContext context)
        {
            var processed = new HashSet <string>();

            if (context.Type is ObjectType ot)
            {
                AddExectableDirectives(processed, ot.Directives);
                AddExectableDirectives(processed, Directives);
            }
        }
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            CompleteIsOfType();
            CompleteInterfaces(context);
            CompleteFields(context);

            ValidateInterfaceImplementation(context);
        }
Beispiel #9
0
        private void ValidateField(
            ITypeInitializationContext context,
            IGrouping <string, InterfaceField> interfaceField)
        {
            InterfaceField first = interfaceField.First();

            if (ValidateInterfaceFieldGroup(context, first, interfaceField))
            {
                ValidateObjectField(context, first);
            }
        }
        protected override void OnRegisterDependencies(
            ITypeInitializationContext context)
        {
            base.OnRegisterDependencies(context);

            foreach (INeedsInitialization field in Fields
                     .Cast <INeedsInitialization>())
            {
                field.RegisterDependencies(context);
            }
        }
Beispiel #11
0
        protected override void OnCompleteType(ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            foreach (INeedsInitialization field in Fields.Cast <INeedsInitialization>())
            {
                field.CompleteType(context);
            }

            CompleteIsOfType();
            CompleteInterfaces(context);
        }
Beispiel #12
0
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            var processed = new HashSet <string>();

            foreach (DirectiveDescription description in _descs)
            {
                CompleteDirective(context, description, processed);
            }

            _lookup = _directives.ToLookup(t => t.Name);
        }
Beispiel #13
0
 protected override void OnCompleteType(
     ITypeInitializationContext context)
 {
     if (!Values.Any())
     {
         context.ReportError(new SchemaError(
                                 string.Format(
                                     CultureInfo.InvariantCulture,
                                     TypeResources.EnumType_NoValues,
                                     Name)));
     }
 }
Beispiel #14
0
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            foreach (INeedsInitialization field in Fields
                     .Cast <INeedsInitialization>())
            {
                field.CompleteType(context);
            }

            CompleteAbstractTypeResolver(context);
        }
Beispiel #15
0
 private void CompleteInterfaces(
     ITypeInitializationContext context)
 {
     if (_interfaces != null)
     {
         foreach (InterfaceType interfaceType in _interfaces
                  .Select(t => context.GetType <InterfaceType>(t))
                  .Where(t => t != null))
         {
             _interfaceMap[interfaceType.Name] = interfaceType;
         }
     }
 }
Beispiel #16
0
 private void ValidateInterfaceImplementation(
     ITypeInitializationContext context)
 {
     if (_interfaceMap.Count > 0)
     {
         foreach (IGrouping <string, InterfaceField> fieldGroup in
                  _interfaceMap.Values
                  .SelectMany(t => t.Fields)
                  .GroupBy(t => t.Name))
         {
             ValidateField(context, fieldGroup);
         }
     }
 }
        private void CompleteClrType(
            ITypeInitializationContext context)
        {
            if (ClrType == null &&
                context.TryGetNativeType(this, out Type clrType))
            {
                ClrType = clrType;
            }

            if (ClrType == null)
            {
                ClrType = typeof(object);
            }
        }
Beispiel #18
0
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            if (context.Type == null)
            {
                throw new InvalidOperationException(
                          "It is not allowed to initialize a field without " +
                          "a type context.");
            }

            DeclaringType = context.Type;
            Type          = context.ResolveFieldType <T>(this, TypeReference);
        }
Beispiel #19
0
 private void CompleteInterfaceFields(
     ITypeInitializationContext context)
 {
     if (context.Type is ObjectType ot && ot.Interfaces.Count > 0)
     {
         foreach (InterfaceType interfaceType in ot.Interfaces.Values)
         {
             if (interfaceType.Fields
                 .TryGetField(Name, out InterfaceField field))
             {
                 _interfaceFields.Add(field);
             }
         }
     }
 }
        private void CompleteFields(
            ITypeInitializationContext context)
        {
            foreach (INeedsInitialization field in Fields
                     .Cast <INeedsInitialization>())
            {
                field.CompleteType(context);
            }

            if (Fields.IsEmpty)
            {
                context.ReportError(new SchemaError(
                                        $"The input object `{Name}` does not have any fields."));
            }
        }
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            ITypeConversion converter = context.Services.GetTypeConversion();

            _objectToValueConverter =
                new InputObjectToObjectValueConverter(converter);
            _valueToObjectConverter =
                new ObjectValueToInputObjectConverter(converter);

            base.OnCompleteType(context);

            CompleteClrType(context);
            CompleteFields(context);
        }
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            if (Resolver == null)
            {
                Resolver = context.GetResolver(Name);
                if (Resolver == null)
                {
                    context.ReportError(new SchemaError(
                                            $"The field `{context.Type.Name}.{Name}` " +
                                            "has no resolver.", context.Type));
                }
            }
        }
Beispiel #23
0
 private void CompleteResolver(
     ITypeInitializationContext context)
 {
     if (Resolver == null)
     {
         Resolver = context.GetResolver(Name);
         if (Resolver == null &&
             _executableDirectives.All(
                 t => t.Middleware == null))
         {
             context.ReportError(new SchemaError(
                                     $"The field `{context.Type.Name}.{Name}` " +
                                     "has no resolver.", context.Type));
         }
     }
 }
Beispiel #24
0
        protected override void OnRegisterDependencies(
            ITypeInitializationContext context)
        {
            base.OnRegisterDependencies(context);

            if (context.Type == null)
            {
                throw new InvalidOperationException(
                          "It is not allowed to initialize a field without " +
                          "a type context.");
            }

            if (TypeReference != null)
            {
                context.RegisterType(TypeReference);
            }
        }
Beispiel #25
0
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            if (Type != null)
            {
                CompleteDefaultValue(context, Type);

                if (context.Type is InputObjectType &&
                    Property == null &&
                    context.TryGetProperty(context.Type, Name, out PropertyInfo property))
                {
                    Property = property;
                }
            }
        }
Beispiel #26
0
        private void RegisterDependencies(
            ITypeInitializationContext context)
        {
            if (_status == TypeStatus.Created)
            {
                _status = TypeStatus.Registering;

                foreach (INeedsInitialization dependency in _dependencies)
                {
                    dependency.RegisterDependencies(context);
                }

                OnRegisterDependencies(context);

                _status = TypeStatus.Registered;
            }
        }
Beispiel #27
0
        private void CompleteType(
            ITypeInitializationContext context)
        {
            if (_status == TypeStatus.Registered)
            {
                _status = TypeStatus.Completing;

                foreach (INeedsInitialization dependency in _dependencies)
                {
                    dependency.CompleteType(context);
                }

                OnCompleteType(context);

                _status = TypeStatus.Completed;
            }
        }
Beispiel #28
0
        protected override void OnCompleteType(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            foreach (INeedsInitialization argument in Arguments
                     .Cast <INeedsInitialization>())
            {
                argument.CompleteType(context);
            }

            if (context.GetMiddleware(Name) is DirectiveDelegateMiddleware m)
            {
                Middleware   = m.Middleware;
                IsExecutable = true;
            }
        }
Beispiel #29
0
        private void CompleteFields(
            ITypeInitializationContext context)
        {
            foreach (INeedsInitialization field in Fields
                     .Cast <INeedsInitialization>())
            {
                field.CompleteType(context);
            }

            if (Fields.IsEmpty)
            {
                context.ReportError(new SchemaError(string.Format(
                                                        CultureInfo.InvariantCulture,
                                                        TypeResources.InputObjectType_NoFields,
                                                        Name)));
            }
        }
Beispiel #30
0
        protected override void OnRegisterDependencies(
            ITypeInitializationContext context)
        {
            base.OnCompleteType(context);

            if (!context.IsDirective && context.Type == null)
            {
                throw new InvalidOperationException(
                          "It is not allowed to initialize a field without " +
                          "a type context.");
            }

            if (TypeReference != null)
            {
                string s = TypeReference.ToString();
                context.RegisterType(TypeReference);
            }
        }