internal void CopyFrom(ProcessingContext context)
 {
     this.processor = context.processor;
     if (context.sequenceStack.frames.Count > 0)
     {
         this.sequenceStack.CopyFrom(ref context.sequenceStack);
     }
     else
     {
         this.sequenceStack.Clear();
     }
     if (context.valueStack.frames.Count > 0)
     {
         this.valueStack.CopyFrom(ref context.valueStack);
     }
     else
     {
         this.valueStack.Clear();
     }
     this.nodeCount = context.nodeCount;
 }
コード例 #2
0
 internal void Push(QueryProcessor p)
 {
     p.next         = this.processor;
     this.processor = p;
 }
コード例 #3
0
        public IEnumerator <KeyValuePair <MessageQuery, TResult> > GetEnumerator()
        {
            QueryProcessor processor = this.matcher.CreateProcessor();
            Collection <KeyValuePair <MessageQuery, XPathResult> > results =
                new Collection <KeyValuePair <MessageQuery, XPathResult> >();

            processor.ResultSet = results;

            try
            {
                processor.Eval(this.matcher.RootOpcode, this.message, this.evalBody);

                if (typeof(TResult) == typeof(XPathResult))
                {
                    return((IEnumerator <KeyValuePair <MessageQuery, TResult> >)(object) results.GetEnumerator());
                }
                else if (typeof(TResult) == typeof(string) ||
                         typeof(TResult) == typeof(bool) ||
                         typeof(TResult) == typeof(object))
                {
                    Collection <KeyValuePair <MessageQuery, TResult> > typedResults =
                        new Collection <KeyValuePair <MessageQuery, TResult> >();

                    foreach (var result in results)
                    {
                        if (typeof(TResult) == typeof(string))
                        {
                            typedResults.Add(
                                new KeyValuePair <MessageQuery, TResult>(
                                    result.Key, (TResult)(object)result.Value.GetResultAsString()));
                        }
                        else if (typeof(TResult) == typeof(bool))
                        {
                            typedResults.Add(
                                new KeyValuePair <MessageQuery, TResult>(
                                    result.Key, (TResult)(object)result.Value.GetResultAsBoolean()));
                        }
                        else
                        {
                            typedResults.Add(new KeyValuePair <MessageQuery, TResult>(
                                                 result.Key, (TResult)(object)result.Value));
                        }
                    }

                    return((IEnumerator <KeyValuePair <MessageQuery, TResult> >)typedResults.GetEnumerator());
                }
                else
                {
                    throw Fx.AssertAndThrowFatal("unsupported type");
                }
            }
            catch (XPathNavigatorException e)
            {
                throw TraceUtility.ThrowHelperError(e.Process(this.matcher.RootOpcode), this.message);
            }
            catch (NavigatorInvalidBodyAccessException e)
            {
                throw TraceUtility.ThrowHelperError(e.Process(this.matcher.RootOpcode), this.message);
            }
            finally
            {
                if (this.evalBody)
                {
                    this.message.Close();
                }

                this.matcher.ReleaseProcessor(processor);
            }
        }