Ejemplo n.º 1
0
        private static async Task <object> CompleteInterfaceValueAsync(
            IExecutorContext executorContext,
            ObjectType actualType,
            IReadOnlyCollection <GraphQLFieldSelection> fields,
            object value,
            NodePath path,
            InterfaceType interfaceType)
        {
            if (!actualType.Implements(interfaceType))
            {
                throw new CompleteValueException(
                          "Cannot complete value as interface. " +
                          $"Actual type {actualType.Name} does not implement {interfaceType.Name}",
                          path,
                          fields.First());
            }

            var subSelectionSet = SelectionSets.MergeSelectionSets(fields);
            var data            = await SelectionSets.ExecuteSelectionSetAsync(
                executorContext,
                subSelectionSet,
                actualType,
                value,
                path).ConfigureAwait(false);

            return(data);
        }
Ejemplo n.º 2
0
    public static object?Handle(
        IExecutorContext context,
        ObjectDefinition objectDefinition,
        string fieldName,
        TypeBase fieldType,
        FieldSelection fieldSelection,
        object?completedValue,
        Exception error,
        NodePath path)
    {
        if (error is not QueryExecutionException)
        {
            error = new QueryExecutionException(
                "",
                error,
                path,
                fieldSelection);
        }

        if (fieldType is NonNullType)
        {
            throw error;
        }

        context.AddError(error);
        return(completedValue);
    }
Ejemplo n.º 3
0
        private static async Task <object> CompleteUnionValueAsync(
            IExecutorContext executorContext,
            ObjectType actualType,
            IReadOnlyCollection <GraphQLFieldSelection> fields,
            object value,
            NodePath path,
            UnionType unionType)
        {
            if (!unionType.IsPossible(actualType))
            {
                throw new CompleteValueException(
                          "Cannot complete value as union. " +
                          $"Actual type {actualType.Name} is not possible for {unionType.Name}",
                          path,
                          fields.First());
            }

            var subSelectionSet = SelectionSets.MergeSelectionSets(fields);
            var data            = await SelectionSets.ExecuteSelectionSetAsync(
                executorContext,
                subSelectionSet,
                actualType,
                value,
                path).ConfigureAwait(false);

            return(data);
        }
Ejemplo n.º 4
0
        public virtual async Task <object> CompleteValueAsync(IExecutorContext executorContext,
                                                              ObjectType objectType,
                                                              IField field,
                                                              IType fieldType,
                                                              GraphQLFieldSelection selection,
                                                              List <GraphQLFieldSelection> fields,
                                                              Dictionary <string, object> coercedVariableValues,
                                                              NodePath path)
        {
            object completedValue = null;

            completedValue = await CompleteValueAsync(
                executorContext,
                objectType,
                field,
                fieldType,
                ActualType,
                selection,
                fields,
                Value,
                coercedVariableValues,
                path).ConfigureAwait(false);

            return(completedValue);
        }
Ejemplo n.º 5
0
        public virtual ExecuteAction Execute(IExecutorContext context)
        {
            _currentIndex++;
            if (_currentIndex == _node.OperandCount)
            {
                Result[] results = new Result[_node.OperandCount];
                for (int i = 0; i < _node.OperandCount; i++)
                {
                    results[i] = _subVisitors[i].Result;
                }
                this.EndVisit(_node.Expression.Eval((Evaluator)context, results));
                return(ExecuteAction.End);
            }

            if (_currentIndex > _node.OperandCount)
            {
                throw new InvalidOperationException();
            }

            ExprNode subNode = (ExprNode)_node.Operands[_currentIndex];

            _subVisitors[_currentIndex] = context.CreateExecutor(subNode);
            context.Push(_subVisitors[_currentIndex]);

            return(ExecuteAction.Continue);
        }
Ejemplo n.º 6
0
        private async Task <object> CompleteNonNullValueAsync(
            IExecutorContext executorContext,
            ObjectType objectType,
            IField field,
            ObjectType actualType,
            GraphQLFieldSelection selection,
            IReadOnlyCollection <GraphQLFieldSelection> fields,
            object value,
            NodePath path,
            NonNull nonNull)
        {
            var innerType       = nonNull.OfType;
            var completedResult = await CompleteValueAsync(
                executorContext,
                objectType,
                field,
                innerType,
                actualType,
                selection,
                fields,
                value,
                path).ConfigureAwait(false);

            if (completedResult == null)
            {
                throw new NullValueForNonNullException(
                          objectType.Name,
                          selection.Name.Value,
                          path,
                          selection);
            }

            return(completedResult);
        }
Ejemplo n.º 7
0
    public async Task <IDictionary <string, object?> > ExecuteGroupedFieldSetAsync(
        IExecutorContext context,
        IReadOnlyDictionary <string, List <FieldSelection> > groupedFieldSet,
        ObjectDefinition objectDefinition,
        object?objectValue,
        NodePath path)
    {
        var tasks = new Dictionary <string, Task <object?> >();

        foreach (var fieldGroup in groupedFieldSet)
        {
            var executionTask = FieldGroups.ExecuteFieldGroupAsync(
                context,
                objectDefinition,
                objectValue,
                //todo: following is dirty
                new KeyValuePair <string, IReadOnlyCollection <FieldSelection> >(fieldGroup.Key,
                                                                                 fieldGroup.Value),
                path.Fork());

            tasks.Add(fieldGroup.Key, executionTask);
        }

        await Task.WhenAll(tasks.Values).ConfigureAwait(false);

        return(tasks.ToDictionary(kv => kv.Key, kv => kv.Value.Result));
    }
Ejemplo n.º 8
0
        private async Task <object> CompleteNonNullValueAsync(
            IExecutorContext executorContext,
            ObjectType objectType,
            IField field,
            ObjectType actualType,
            GraphQLFieldSelection selection,
            List <GraphQLFieldSelection> fields,
            object value, Dictionary <string, object> coercedVariableValues,
            NodePath path,
            NonNull nonNull)
        {
            var innerType       = nonNull.WrappedType;
            var completedResult = await CompleteValueAsync(
                executorContext,
                objectType,
                field,
                innerType,
                actualType,
                selection,
                fields,
                value,
                coercedVariableValues,
                path).ConfigureAwait(false);

            if (completedResult == null)
            {
                throw new NullValueForNonNullException(
                          objectType.Name,
                          selection.Name.Value,
                          path,
                          selection);
            }

            return(completedResult);
        }
Ejemplo n.º 9
0
        public override async Task <IDictionary <string, object> > ExecuteGroupedFieldSetAsync(
            IExecutorContext context,
            Dictionary <string, List <GraphQLFieldSelection> > groupedFieldSet,
            ObjectType objectType, object objectValue,
            Dictionary <string, object> coercedVariableValues,
            NodePath path)
        {
            var data  = new ConcurrentDictionary <string, object>();
            var tasks = new ConcurrentBag <Task>();

            foreach (var fieldGroup in groupedFieldSet)
            {
                var executionTask = Task.Run(async() =>
                {
                    var responseKey = fieldGroup.Key;
                    var result      = await ExecuteFieldGroupAsync(
                        context,
                        objectType,
                        objectValue,
                        coercedVariableValues,
                        fieldGroup,
                        path.Fork()).ConfigureAwait(false);

                    data[responseKey] = result;
                });

                tasks.Add(executionTask);
            }

            await Task.WhenAll(tasks).ConfigureAwait(false);

            return(data);
        }
Ejemplo n.º 10
0
        public static object Handle(
            IExecutorContext context,
            ObjectType objectType,
            string fieldName,
            IType fieldType,
            GraphQLFieldSelection fieldSelection,
            object completedValue,
            Exception error,
            NodePath path)
        {
            if (!(error is QueryExecutionException))
            {
                error = new QueryExecutionException(
                    "",
                    error,
                    path,
                    fieldSelection);
            }

            if (fieldType is NonNull)
            {
                throw error;
            }

            context.AddError(error);
            return(completedValue);
        }
Ejemplo n.º 11
0
        public override ExecuteAction Execute(IExecutorContext context)
        {
            this.CurrentIndex++;
            if (this.CurrentIndex == 0)
            {
                this.SubVisitors[this.CurrentIndex] = context.CreateExecutor((ExprNode)this.Node.Operands[this.CurrentIndex]);
                context.Push(this.SubVisitors[this.CurrentIndex]);
                return ExecuteAction.Continue; 
            }
            else if (this.CurrentIndex == 1)
            {
                Result result = this.SubVisitors[0].Result;
                int resultIndex = -1;
                if ((bool) ConvertHelper.ChangeType(result.Value, typeof(bool)))
                {
                    resultIndex = 1;
                }
                else
                {
                    resultIndex = 2;
                }
                this.SubVisitors[1] = context.CreateExecutor((ExprNode)this.Node.Operands[resultIndex]);
                context.Push(this.SubVisitors[1]);

                return ExecuteAction.Continue;
            }
            else
            {
                this.EndVisit(this.SubVisitors[1].Result); 
                return ExecuteAction.End;
            }
        }
Ejemplo n.º 12
0
        private static async Task <ExecutionResult> ExecuteSubscriptionEventAsync(
            IExecutorContext context,
            OperationDefinition subscription,
            IReadOnlyDictionary <string, object?> coercedVariableValues,
            object evnt,
            Func <Exception, ExecutionError> formatError)
        {
            var subscriptionType = context.Schema.Subscription;
            var selectionSet     = subscription.SelectionSet;
            var path             = new NodePath();
            var data             = await SelectionSets.ExecuteSelectionSetAsync(
                context,
                selectionSet,
                subscriptionType,
                evnt,
                path).ConfigureAwait(false);

            var result = new ExecutionResult
            {
                Errors = context.FieldErrors.Select(formatError).ToList(),
                Data   = data?.ToDictionary(kv => kv.Key, kv => kv.Value)
            };

            return(result);
        }
Ejemplo n.º 13
0
    public async Task <IDictionary <string, object?> > ExecuteGroupedFieldSetAsync(
        IExecutorContext context,
        IReadOnlyDictionary <string, List <FieldSelection> > groupedFieldSet,
        ObjectDefinition objectDefinition,
        object?objectValue,
        NodePath path)
    {
        var responseMap = new Dictionary <string, object?>();

        foreach (var fieldGroup in groupedFieldSet)
        {
            var responseKey = fieldGroup.Key;

            try
            {
                var result = await FieldGroups.ExecuteFieldGroupAsync(
                    context,
                    objectDefinition,
                    objectValue,
                    new KeyValuePair <string, IReadOnlyCollection <FieldSelection> >(fieldGroup.Key, fieldGroup.Value),
                    path.Fork()).ConfigureAwait(false);

                responseMap[responseKey] = result;
            }
            catch (QueryExecutionException e)
            {
                responseMap[responseKey] = null;
                context.AddError(e);
            }
        }

        return(responseMap);
    }
Ejemplo n.º 14
0
 public override ExecuteAction Execute(IExecutorContext context)
 {
     base.CurrentIndex++;
     if (base.CurrentIndex == 0)
     {
         base.SubVisitors[base.CurrentIndex] = context.CreateExecutor((ExprNode)base.Node.Operands[base.CurrentIndex]);
         context.Push(base.SubVisitors[base.CurrentIndex]);
         return(ExecuteAction.Continue);
     }
     if (base.CurrentIndex == 1)
     {
         Result result = base.SubVisitors[0].Result;
         int    num    = -1;
         if ((bool)result.Value)
         {
             num = 1;
         }
         else
         {
             num = 2;
         }
         base.SubVisitors[1] = context.CreateExecutor((ExprNode)base.Node.Operands[num]);
         context.Push(base.SubVisitors[1]);
         return(ExecuteAction.Continue);
     }
     base.EndVisit(base.SubVisitors[1].Result);
     return(ExecuteAction.End);
 }
Ejemplo n.º 15
0
        public override ExecuteAction Execute(IExecutorContext context)
        {
            this.CurrentIndex++;
            if (this.CurrentIndex == 0)
            {
                this.SubVisitors[this.CurrentIndex] = context.CreateExecutor((ExprNode)this.Node.Operands[this.CurrentIndex]);
                context.Push(this.SubVisitors[this.CurrentIndex]);
                return(ExecuteAction.Continue);
            }
            else if (this.CurrentIndex == 1)
            {
                Result result      = this.SubVisitors[0].Result;
                int    resultIndex = -1;
                if ((bool)result.Value)
                {
                    resultIndex = 1;
                }
                else
                {
                    resultIndex = 2;
                }
                this.SubVisitors[1] = context.CreateExecutor((ExprNode)this.Node.Operands[resultIndex]);
                context.Push(this.SubVisitors[1]);

                return(ExecuteAction.Continue);
            }
            else
            {
                this.EndVisit(this.SubVisitors[1].Result);
                return(ExecuteAction.End);
            }
        }
Ejemplo n.º 16
0
        private async Task <object> CompleteListValueAsync(
            IExecutorContext executorContext,
            ObjectType objectType,
            IField field,
            IType fieldType,
            ObjectType actualType,
            GraphQLFieldSelection selection,
            IReadOnlyCollection <GraphQLFieldSelection> fields,
            object value,
            NodePath path,
            List listType)
        {
            if (!(value is IEnumerable values))
            {
                throw new CompleteValueException(
                          $"Cannot complete value for list field '{selection.Name.Value}':'{fieldType}'. " +
                          "Resolved value is not a collection",
                          path,
                          selection);
            }

            var innerType = listType.OfType;
            var result    = new List <object>();
            int i         = 0;

            foreach (var resultItem in values)
            {
                var itemPath = path.Fork().Append(i++);
                try
                {
                    var completedResultItem = await CompleteValueAsync(
                        executorContext,
                        objectType,
                        field,
                        innerType,
                        actualType,
                        selection,
                        fields,
                        resultItem,
                        itemPath).ConfigureAwait(false);

                    result.Add(completedResultItem);
                }
                catch (Exception e)
                {
                    if (innerType is NonNull)
                    {
                        throw;
                    }

                    executorContext.AddError(e);
                    result.Add(null);
                }
            }

            return(result);
        }
Ejemplo n.º 17
0
		public override ExecuteAction Execute(IExecutorContext context) {
			if (this.CurrentIndex == 0) {
				Result result = this.SubVisitors[0].Result;
				if ((bool)result.Value) {
					this.EndVisit(new Result(true));
					return ExecuteAction.End;
				} else {
					return base.Execute(context);
				}
			}
			return base.Execute(context);
		}
Ejemplo n.º 18
0
 public override ExecuteAction Execute(IExecutorContext context)
 {
     if (base.CurrentIndex == 0)
     {
         if ((bool)base.SubVisitors[0].Result.Value)
         {
             base.EndVisit(new Result(true));
             return(ExecuteAction.End);
         }
         return(base.Execute(context));
     }
     return(base.Execute(context));
 }
Ejemplo n.º 19
0
        private static async Task <object> CompleteObjectValueAsync(IExecutorContext executorContext, List <GraphQLFieldSelection> fields, object value,
                                                                    Dictionary <string, object> coercedVariableValues, NodePath path, ObjectType fieldObjectType)
        {
            var subSelectionSet = SelectionSets.MergeSelectionSets(fields);
            var data            = await SelectionSets.ExecuteSelectionSetAsync(
                executorContext,
                subSelectionSet,
                fieldObjectType,
                value,
                coercedVariableValues,
                path).ConfigureAwait(false);

            return(data);
        }
Ejemplo n.º 20
0
        private static async Task <object> CompleteObjectValueAsync(
            IExecutorContext executorContext,
            IReadOnlyCollection <GraphQLFieldSelection> fields,
            object value,
            NodePath path,
            ObjectType fieldObjectType)
        {
            var subSelectionSet = SelectionSets.MergeSelectionSets(fields);
            var data            = await SelectionSets.ExecuteSelectionSetAsync(
                executorContext,
                subSelectionSet,
                fieldObjectType,
                value,
                path).ConfigureAwait(false);

            return(data);
        }
Ejemplo n.º 21
0
        protected async Task <object> ExecuteFieldGroupAsync(
            IExecutorContext context,
            ObjectType objectType,
            object objectValue,
            Dictionary <string, object> coercedVariableValues,
            KeyValuePair <string, List <GraphQLFieldSelection> > fieldGroup,
            NodePath path)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException(nameof(objectType));
            }

            var schema    = context.Schema;
            var fields    = fieldGroup.Value;
            var fieldName = fields.First().Name.Value;

            path.Append(fieldName);

            // __typename hack
            if (fieldName == "__typename")
            {
                return(objectType.Name);
            }

            var fieldType = schema
                            .GetField(objectType.Name, fieldName)?
                            .Type;

            if (fieldType == null)
            {
                throw new GraphQLError(
                          $"Object '{objectType.Name}' does not have field '{fieldName}'");
            }

            var responseValue = await ExecuteFieldAsync(
                context,
                objectType,
                objectValue,
                fields,
                fieldType,
                coercedVariableValues,
                path).ConfigureAwait(false);

            return(responseValue);
        }
Ejemplo n.º 22
0
 public override ExecuteAction Execute(IExecutorContext context)
 {
     if (this.CurrentIndex == 0)
     {
         Result result = this.SubVisitors[0].Result;
         if (!(bool) ConvertHelper.ChangeType(result.Value, typeof(bool)))
         {
             this.EndVisit(new Result(false)); 
             return ExecuteAction.End;
         }
         else
         {
             return base.Execute(context);
         }
     }
     return base.Execute(context);
 }
Ejemplo n.º 23
0
 public override ExecuteAction Execute(IExecutorContext context)
 {
     if (this.CurrentIndex == 0)
     {
         Result result = this.SubVisitors[0].Result;
         if (!(bool)ConvertHelper.ChangeType(result.Value, typeof(bool)))
         {
             this.EndVisit(new Result(false));
             return(ExecuteAction.End);
         }
         else
         {
             return(base.Execute(context));
         }
     }
     return(base.Execute(context));
 }
Ejemplo n.º 24
0
 public override ExecuteAction Execute(IExecutorContext context)
 {
     if (this.CurrentIndex == 0)
     {
         Result result = this.SubVisitors[0].Result;
         if ((bool)result.Value)
         {
             this.EndVisit(new Result(true));
             return(ExecuteAction.End);
         }
         else
         {
             return(base.Execute(context));
         }
     }
     return(base.Execute(context));
 }
Ejemplo n.º 25
0
        public static async Task <object> ExecuteFieldGroupAsync(
            IExecutorContext context,
            ObjectType objectType,
            object objectValue,
            KeyValuePair <string, IReadOnlyCollection <GraphQLFieldSelection> > fieldGroup,
            NodePath path)
        {
            if (objectType == null)
            {
                throw new ArgumentNullException(nameof(objectType));
            }

            var schema    = context.Schema;
            var fields    = fieldGroup.Value;
            var fieldName = fields.First().Name.Value;

            path.Append(fieldName);

            // __typename hack
            if (fieldName == "__typename")
            {
                return(objectType.Name);
            }

            var fieldType = schema
                            .GetField(objectType.Name, fieldName)?
                            .Type;

            if (fieldType == null)
            {
                throw new QueryExecutionException(
                          $"Object '{objectType.Name}' does not have field '{fieldName}'",
                          path);
            }

            var responseValue = await ExecuteFieldAsync(
                context,
                objectType,
                objectValue,
                fields,
                fieldType,
                path).ConfigureAwait(false);

            return(responseValue);
        }
Ejemplo n.º 26
0
 public ResolverContext(
     ObjectType objectType,
     object objectValue,
     IField field,
     FieldSelection selection,
     IReadOnlyCollection <FieldSelection> fields,
     IReadOnlyDictionary <string, object?> arguments,
     NodePath path,
     IExecutorContext executionContext)
 {
     ObjectType       = objectType ?? throw new ArgumentNullException(nameof(objectType));
     ObjectValue      = objectValue;
     Field            = field ?? throw new ArgumentNullException(nameof(field));
     Selection        = selection ?? throw new ArgumentNullException(nameof(selection));
     Fields           = fields;
     Arguments        = arguments ?? throw new ArgumentNullException(nameof(arguments));
     Path             = path ?? throw new ArgumentNullException(nameof(path));
     ExecutionContext = executionContext;
 }
Ejemplo n.º 27
0
 public ResolverContext(
     ISchema schema, //todo: remove and get from execution
     ObjectType objectType,
     object objectValue,
     IField field,
     GraphQLFieldSelection selection,
     IReadOnlyDictionary <string, object> arguments,
     NodePath path,
     IExecutorContext executionContext)
 {
     Schema           = schema ?? throw new ArgumentNullException(nameof(schema));
     ObjectType       = objectType ?? throw new ArgumentNullException(nameof(objectType));
     ObjectValue      = objectValue;
     Field            = field ?? throw new ArgumentNullException(nameof(field));
     Selection        = selection ?? throw new ArgumentNullException(nameof(selection));
     Arguments        = arguments ?? throw new ArgumentNullException(nameof(arguments));
     Path             = path ?? throw new ArgumentNullException(nameof(path));
     ExecutionContext = executionContext;
 }
Ejemplo n.º 28
0
        public static SubscriptionResult MapSourceToResponseEventAsync(
            IExecutorContext context,
            ISubscriberResult subscriberResult,
            OperationDefinition subscription,
            IReadOnlyDictionary <string, object?> coercedVariableValues,
            Func <Exception, ExecutionError> formatError,
            CancellationToken cancellationToken)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (subscriberResult == null)
            {
                throw new ArgumentNullException(nameof(subscriberResult));
            }
            if (subscription == null)
            {
                throw new ArgumentNullException(nameof(subscription));
            }
            if (coercedVariableValues == null)
            {
                throw new ArgumentNullException(nameof(coercedVariableValues));
            }
            if (formatError == null)
            {
                throw new ArgumentNullException(nameof(formatError));
            }

            var responseStream = Channel.CreateUnbounded <ExecutionResult>();
            var reader         = subscriberResult.Reader;

            // execute event
            var _ = reader.TransformAndWriteTo(responseStream, item => ExecuteSubscriptionEventAsync(
                                                   context,
                                                   subscription,
                                                   coercedVariableValues,
                                                   item,
                                                   formatError));

            return(new SubscriptionResult(responseStream));
        }
Ejemplo n.º 29
0
		public virtual ExecuteAction Execute(IExecutorContext context) {
			_currentIndex++;
			if (_currentIndex == _node.OperandCount) {
				Result[] results = new Result[_node.OperandCount];
				for (int i = 0; i < _node.OperandCount; i++)
					results[i] = _subVisitors[i].Result;
				this.EndVisit(_node.Expression.Eval((Evaluator)context, results));
				return ExecuteAction.End;
			}

			if (_currentIndex > _node.OperandCount) {
				throw new InvalidOperationException();
			}

			ExprNode subNode = (ExprNode)_node.Operands[_currentIndex];
			_subVisitors[_currentIndex] = context.CreateExecutor(subNode);
			context.Push(_subVisitors[_currentIndex]);

			return ExecuteAction.Continue;
		}
Ejemplo n.º 30
0
        public Task <object> CompleteValueAsync(IExecutorContext executorContext,
                                                ObjectType objectType,
                                                IField field,
                                                IType fieldType,
                                                GraphQLFieldSelection selection,
                                                IReadOnlyCollection <GraphQLFieldSelection> fields,
                                                NodePath path)
        {
            var value         = _data[selection.Name.Value];
            var resolveResult = new ResolveResult(value);

            return(resolveResult.CompleteValueAsync(
                       executorContext,
                       objectType,
                       field,
                       fieldType,
                       selection,
                       fields,
                       path));
        }
Ejemplo n.º 31
0
        public virtual async Task <object> CompleteValueAsync(IExecutorContext executorContext,
                                                              ObjectType objectType,
                                                              IField field,
                                                              IType fieldType,
                                                              GraphQLFieldSelection selection,
                                                              IReadOnlyCollection <GraphQLFieldSelection> fields,
                                                              NodePath path)
        {
            object completedValue = null;

            completedValue = await CompleteValueAsync(
                executorContext,
                objectType,
                field,
                fieldType,
                ActualType,
                selection,
                fields,
                Value,
                path).ConfigureAwait(false);

            return(completedValue);
        }
Ejemplo n.º 32
0
        public static async Task <IDictionary <string, object> > ExecuteSelectionSetAsync(
            IExecutorContext executorContext,
            GraphQLSelectionSet selectionSet,
            ObjectType objectType,
            object objectValue,
            NodePath path)
        {
            var groupedFieldSet = CollectFields(
                executorContext.Schema,
                executorContext.Document,
                objectType,
                selectionSet,
                executorContext.CoercedVariableValues);

            var resultMap = await executorContext.Strategy.ExecuteGroupedFieldSetAsync(
                executorContext,
                groupedFieldSet,
                objectType,
                objectValue,
                path).ConfigureAwait(false);

            return(resultMap);
        }
Ejemplo n.º 33
0
        public virtual ExecuteAction Execute(IExecutorContext context)
        {
            this._currentIndex++;
            if (this._currentIndex == this._node.OperandCount)
            {
                OPCTrendLib.Result[] argArray = new OPCTrendLib.Result[this._node.OperandCount];
                for (int i = 0; i < this._node.OperandCount; i++)
                {
                    argArray[i] = this._subVisitors[i].Result;
                }
                this.EndVisit(this._node.Expression.Eval((Evaluator)context, argArray));
                return(ExecuteAction.End);
            }
            if (this._currentIndex > this._node.OperandCount)
            {
                throw new InvalidOperationException();
            }
            ExprNode node = (ExprNode)this._node.Operands[this._currentIndex];

            this._subVisitors[this._currentIndex] = context.CreateExecutor(node);
            context.Push(this._subVisitors[this._currentIndex]);
            return(ExecuteAction.Continue);
        }
Ejemplo n.º 34
0
        public Task <object> CompleteValueAsync(
            IExecutorContext executorContext,
            ObjectType objectType,
            IField field,
            IType fieldType,
            GraphQLFieldSelection selection,
            List <GraphQLFieldSelection> fields,
            Dictionary <string, object> coercedVariableValues,
            NodePath path)
        {
            var value         = _data[selection.Name.Value];
            var resolveResult = new ResolveResult(value);

            return(resolveResult.CompleteValueAsync(
                       executorContext,
                       objectType,
                       field,
                       fieldType,
                       selection,
                       fields,
                       coercedVariableValues,
                       path));
        }
Ejemplo n.º 35
0
 public virtual void Initialize(IExecutorContext context, ExprNode node)
 {
     _node = node;
     Reset(context);
 }
Ejemplo n.º 36
0
 public virtual void Reset(IExecutorContext context)
 {
     _subVisitors = new IExecutor[_node.OperandCount];
     _currentIndex = -1;
 }
Ejemplo n.º 37
0
		public override void Reset(IExecutorContext context) {
			base.Reset(context);
		}
Ejemplo n.º 38
0
		public override ExecuteAction Execute(IExecutorContext context) {
			return base.Execute(context);
		}
Ejemplo n.º 39
0
		public override ExecuteAction Execute(IExecutorContext context) {
			this.EndVisit(this.Node.Expression.Eval((Evaluator)context, null));
			return ExecuteAction.End;
		}
Ejemplo n.º 40
0
		public override void Reset(IExecutorContext context) {
		}