示例#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;
        }
示例#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;
     }
 }
示例#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));
     }
 }
示例#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;
        }