public JobAlbumArt Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            JobAlbumArt jobAlbumArt = new JobAlbumArt();


            int targetDepth = context.CurrentDepth;

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

                if (context.TestExpression("Artwork", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Artwork, ArtworkUnmarshaller>(
                        ArtworkUnmarshaller.GetInstance());
                    jobAlbumArt.Artwork = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(jobAlbumArt);
        }
Exemple #2
0
        public JobAlbumArt Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            JobAlbumArt jobAlbumArt = new JobAlbumArt();



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

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

                if (context.TestExpression("Artwork", targetDepth))
                {
                    context.Read();

                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        jobAlbumArt.Artwork = null;
                        continue;
                    }
                    jobAlbumArt.Artwork = new List <Artwork>();
                    ArtworkUnmarshaller unmarshaller = ArtworkUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        jobAlbumArt.Artwork.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

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


            return(jobAlbumArt);
        }