Esempio n. 1
0
        protected FieldBase(
            FieldDescriptionBase description,
            DirectiveLocation location)
        {
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            if (string.IsNullOrEmpty(description.Name))
            {
                throw new ArgumentException(
                          "The name of a field mustn't be null or empty.",
                          nameof(description));
            }

            Name          = description.Name;
            Description   = description.Description;
            TypeReference = description.TypeReference;

            var directives = new DirectiveCollection(
                this,
                location,
                description.Directives);

            RegisterForInitialization(directives);

            Directives = directives;
        }
Esempio n. 2
0
 internal static void AcquireNonNullStatus(
     this FieldDescriptionBase fieldDescription,
     MemberInfo member)
 {
     if (member.IsDefined(typeof(GraphQLNonNullTypeAttribute)))
     {
         var attribute =
             member.GetCustomAttribute <GraphQLNonNullTypeAttribute>();
         fieldDescription.IsNullable        = attribute.IsNullable;
         fieldDescription.IsElementNullable = attribute.IsElementNullable;
     }
 }
Esempio n. 3
0
 internal static void RewriteClrType(
     this FieldDescriptionBase fieldDescription,
     Func <Type, TypeReference> createContext)
 {
     if (fieldDescription.IsNullable.HasValue &&
         fieldDescription.TypeReference.IsClrTypeReference())
     {
         fieldDescription.TypeReference = createContext(
             DotNetTypeInfoFactory.Rewrite(
                 fieldDescription.TypeReference.ClrType,
                 !fieldDescription.IsNullable.Value,
                 !fieldDescription.IsElementNullable.Value));
     }
 }
Esempio n. 4
0
        protected FieldBase(FieldDescriptionBase description)
        {
            if (description == null)
            {
                throw new ArgumentNullException(nameof(description));
            }

            if (string.IsNullOrEmpty(description.Name))
            {
                throw new ArgumentException(
                          "The name of a field mustn't be null or empty.",
                          nameof(description));
            }

            Name          = description.Name;
            Description   = description.Description;
            TypeReference = description.TypeReference;
        }