Beispiel #1
0
 public static OfferingUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new OfferingUnmarshaller();
     }
     return(instance);
 }
        public DescribeOfferingsResult Unmarshall(JsonUnmarshallerContext context)
        {
            DescribeOfferingsResult describeOfferingsResult = new DescribeOfferingsResult();

            describeOfferingsResult.Offerings = null;

            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if ((context.IsKey) && (context.CurrentDepth == targetDepth))
                {
                    context.Read();
                    context.Read();

                    if (context.TestExpression("Offerings", targetDepth))
                    {
                        describeOfferingsResult.Offerings = new List <Offering>();
                        OfferingUnmarshaller unmarshaller = OfferingUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                describeOfferingsResult.Offerings.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(describeOfferingsResult);
                }
            }


            return(describeOfferingsResult);
        }