コード例 #1
0
        private static void UnmarshallResult(XmlUnmarshallerContext context, SelectResponse response)
        {
            
            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            
            if (context.IsStartOfDocument) 
               targetDepth += 2;
            
            while (context.ReadAtDepth(originalDepth))
            {
                if (context.IsStartElement || context.IsAttribute)
                {

                    if (context.TestExpression("Item", targetDepth))
                    {
                        var unmarshaller = ItemUnmarshaller.Instance;
                        var item = unmarshaller.Unmarshall(context);
                        response.Items.Add(item);
                        continue;
                    }
                    if (context.TestExpression("NextToken", targetDepth))
                    {
                        var unmarshaller = StringUnmarshaller.Instance;
                        response.NextToken = unmarshaller.Unmarshall(context);
                        continue;
                    }
                } 
           }

            return;
        }
コード例 #2
0
        public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context)
        {
            SelectResponse response = new SelectResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;
            while (context.ReadAtDepth(targetDepth))
            {
                if (context.IsStartElement)
                {                    
                    if(context.TestExpression("SelectResult", 2))
                    {
                        UnmarshallResult(context, response);                        
                        continue;
                    }
                    
                    if (context.TestExpression("ResponseMetadata", 2))
                    {
                        response.ResponseMetadata = ResponseMetadataUnmarshaller.Instance.Unmarshall(context);
                    }
                }
            }

            return response;
        }
コード例 #3
0
        SelectResponse AmazonSimpleDB.Select(SelectRequest request)
        {
            var match = QueryAnalyzer.Match(request.SelectExpression);

            if (!match.Success)
            {
                throw new InvalidOperationException("The specified request does not contain a valid select expression.");
            }

            var attributes = match.Groups[1].Value;
            var domain = match.Groups[2].Value;
            Dictionary<string, Dictionary<string, string>> items;

            if (!Domains.TryGetValue(domain, out items))
            {
                throw new InvalidOperationException("The specified domain does not exist.");
            }

            var skip = 0;

            if (request.IsSetNextToken())
            {
                int.TryParse(request.NextToken, out skip);
            }
            
            var result = new SelectResponse()
                .WithSelectResult(new SelectResult()
                    .WithItem(IntoItem(items
                        .Skip(skip)
                        .Take(MaxItems))));

            if (result.SelectResult.Item.Count == MaxItems)
            {
                result.SelectResult.WithNextToken((skip + MaxItems).ToString());
            }

            ++SelectCount;
            return result;
        }
コード例 #4
0
        private static void UnmarshallResult(XmlUnmarshallerContext context,SelectResponse response)
        {
            
            int originalDepth = context.CurrentDepth;
            int targetDepth = originalDepth + 1;
            
            if (context.IsStartOfDocument) 
               targetDepth += 2;
            
            while (context.Read())
            {
                if (context.IsStartElement || context.IsAttribute)
                {
                    if (context.TestExpression("Item", targetDepth))
                    {
                        response.Items.Add(ItemUnmarshaller.GetInstance().Unmarshall(context));
                            
                        continue;
                    }
                    if (context.TestExpression("NextToken", targetDepth))
                    {
                        response.NextToken = StringUnmarshaller.GetInstance().Unmarshall(context);
                            
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth < originalDepth)
                {
                    return;
                }
            }
                            


            return;
        }