示例#1
0
        private static void DeclareValues(
            IEnumTypeDescriptor typeDescriptor,
            IReadOnlyCollection <EnumValueDefinitionNode> values)
        {
            foreach (EnumValueDefinitionNode value in values)
            {
                IEnumValueDescriptor valueDescriptor =
                    typeDescriptor
                    .Value(value.Name.Value)
                    .Description(value.Description?.Value)
                    .Name(value.Name.Value);

                if (value.DeprecationReason() is { Length: > 0 } s)
                {
                    valueDescriptor.Deprecated(s);
                }

                foreach (DirectiveNode directive in value.Directives)
                {
                    if (!directive.IsDeprecationReason())
                    {
                        valueDescriptor.Directive(directive);
                    }
                }
            }
        }
        private static void DeclareValues(
            IEnumTypeDescriptor typeDescriptor,
            IReadOnlyCollection <EnumValueDefinitionNode> values)
        {
            foreach (EnumValueDefinitionNode value in values)
            {
                IEnumValueDescriptor valueDescriptor =
                    typeDescriptor.Value(value.Name.Value)
                    .Description(value.Description?.Value);

                string deprecactionReason = value.DeprecationReason();
                if (!string.IsNullOrEmpty(deprecactionReason))
                {
                    valueDescriptor.Deprecated(deprecactionReason);
                }

                foreach (DirectiveNode directive in value.Directives)
                {
                    if (!directive.IsDeprecationReason())
                    {
                        valueDescriptor.Directive(directive);
                    }
                }
            }
        }