Ejemplo n.º 1
0
        public static IDirectiveCollection CreateAndComplete(
            ITypeCompletionContext context,
            object source,
            IEnumerable <DirectiveDefinition> directiveDefinitions)
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

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

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

            if (!directiveDefinitions.Any())
            {
                return(EmptyDirectiveCollection.Default);
            }

            var directives = new DirectiveCollection(source, directiveDefinitions);

            directives.CompleteCollection(context);
            return(directives);
        }
Ejemplo n.º 2
0
        public EnumValue(
            ITypeCompletionContext completionContext,
            EnumValueDefinition enumValueDefinition)
        {
            if (completionContext == null)
            {
                throw new ArgumentNullException(nameof(completionContext));
            }

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

            if (enumValueDefinition.Value is null)
            {
                throw new ArgumentException(
                          TypeResources.EnumValue_ValueIsNull,
                          nameof(enumValueDefinition));
            }

            SyntaxNode = enumValueDefinition.SyntaxNode;
            Name       = enumValueDefinition.Name.HasValue
                ? enumValueDefinition.Name
                : (NameString)enumValueDefinition.Value.ToString();
            Description       = enumValueDefinition.Description;
            DeprecationReason = enumValueDefinition.DeprecationReason;
            IsDeprecated      = !string.IsNullOrEmpty(
                enumValueDefinition.DeprecationReason);
            Value       = enumValueDefinition.Value;
            ContextData = enumValueDefinition.ContextData;

            _directives = new DirectiveCollection(this, enumValueDefinition !.Directives);
            _directives.CompleteCollection(completionContext);
        }
Ejemplo n.º 3
0
        protected override void OnCompleteType(
            ICompletionContext context,
            TDefinition definition)
        {
            base.OnCompleteType(context, definition);

            var directives = new DirectiveCollection(
                this, definition.Directives);
            directives.CompleteCollection(context);
            Directives = directives;
        }
Ejemplo n.º 4
0
        internal void CompleteValue(ITypeCompletionContext context)
        {
            var directives = new DirectiveCollection(
                this, _definition.Directives);

            directives.CompleteCollection(context);
            Directives = directives;

            OnCompleteValue(context, _definition);

            _contextData = new Dictionary <string, object>(
                _definition.ContextData);
            _definition = null;
        }
Ejemplo n.º 5
0
        protected virtual void OnCompleteField(
            ICompletionContext context,
            TDefinition definition)
        {
            DeclaringType = context.Type;
            Type          = context.GetType <TType>(_definition.Type);
            ClrType       = Type is IHasClrType hasClrType
                ? hasClrType.ClrType
                : typeof(object);

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

            directives.CompleteCollection(context);
            Directives = directives;
        }
Ejemplo n.º 6
0
        internal void CompleteField(ICompletionContext context)
        {
            DeclaringType = context.Type;
            Type          = context.GetType <TType>(_definition.Type);
            ClrType       = Type.NamedType() is IHasClrType hasClrType
                ? hasClrType.ClrType
                : typeof(object);

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

            directives.CompleteCollection(context);
            Directives = directives;

            OnCompleteField(context, _definition);
            _definition = null;
        }