Ejemplo n.º 1
0
        private async Task <IEnumerable <Traverser> > SubmitBytecodeAsync(Guid requestid, Bytecode bytecode)
        {
            var requestMsg =
                RequestMessage.Build(Tokens.OpsBytecode)
                .Processor(Processor)
                .OverrideRequestId(requestid)
                .AddArgument(Tokens.ArgsGremlin, bytecode)
                .AddArgument(Tokens.ArgsAliases, new Dictionary <string, string> {
                { "g", _traversalSource }
            });

            if (IsSessionBound)
            {
                requestMsg.AddArgument(Tokens.ArgsSession, _sessionId);
            }

            var optionsStrategyInst = bytecode.SourceInstructions.Find(
                s => s.OperatorName == "withStrategies" && s.Arguments[0] is OptionsStrategy);

            if (optionsStrategyInst != null)
            {
                OptionsStrategy optionsStrategy = optionsStrategyInst.Arguments[0];
                foreach (KeyValuePair <string, dynamic> pair in optionsStrategy.Configuration)
                {
                    if (_allowedKeys.Contains(pair.Key))
                    {
                        requestMsg.AddArgument(pair.Key, pair.Value);
                    }
                }
            }

            return(await _client.SubmitAsync <Traverser>(requestMsg.Create()).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public GraphTraversalSource With(string key, object value)
        {
            var optionsStrategyInst = Bytecode.SourceInstructions.Find(
                inst => inst.OperatorName == "withStrategies" && inst.Arguments[0] is OptionsStrategy);
            OptionsStrategy optionsStrategy;

            if (optionsStrategyInst == null)
            {
                optionsStrategy = new OptionsStrategy();
                optionsStrategy.Configuration[key] = value;
                return(WithStrategies(optionsStrategy));
            }

            optionsStrategy = optionsStrategyInst.Arguments[0];
            optionsStrategy.Configuration[key] = value;
            return(new GraphTraversalSource(new List <ITraversalStrategy>(TraversalStrategies),
                                            new Bytecode(Bytecode)));
        }