public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            ListLocalDisksResponse response = new ListLocalDisksResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("GatewayARN", targetDepth))
                {
                    response.GatewayARN = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Disks", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Disk, DiskUnmarshaller>(
                        DiskUnmarshaller.GetInstance());
                    response.Disks = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(response);
        }
Пример #2
0
 public static DiskUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new DiskUnmarshaller();
     }
     return(instance);
 }
        public ListLocalDisksResult Unmarshall(JsonUnmarshallerContext context)
        {
            ListLocalDisksResult listLocalDisksResult = new ListLocalDisksResult();

            listLocalDisksResult.Disks = 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("GatewayARN", targetDepth))
                    {
                        listLocalDisksResult.GatewayARN = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

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


            return(listLocalDisksResult);
        }
Пример #4
0
        private static void UnmarshallResult(JsonUnmarshallerContext context, ListLocalDisksResponse response)
        {
            int originalDepth = context.CurrentDepth;
            int targetDepth   = originalDepth + 1;

            while (context.Read())
            {
                if (context.TestExpression("GatewayARN", targetDepth))
                {
                    context.Read();
                    response.GatewayARN = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Disks", targetDepth))
                {
                    context.Read();
                    response.Disks = new List <Disk>();
                    DiskUnmarshaller unmarshaller = DiskUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        response.Disks.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.CurrentDepth <= originalDepth)
                {
                    return;
                }
            }

            return;
        }