Example #1
0
 public static JobAlbumArtUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new JobAlbumArtUnmarshaller();
     }
     return(instance);
 }
        public JobOutput Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonUnmarshallerContext.TokenType.Null)
            {
                return(null);
            }
            JobOutput jobOutput = new JobOutput();

            jobOutput.Watermarks = 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("Id", targetDepth))
                    {
                        jobOutput.Id = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Key", targetDepth))
                    {
                        jobOutput.Key = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("ThumbnailPattern", targetDepth))
                    {
                        jobOutput.ThumbnailPattern = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Rotate", targetDepth))
                    {
                        jobOutput.Rotate = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("PresetId", targetDepth))
                    {
                        jobOutput.PresetId = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("SegmentDuration", targetDepth))
                    {
                        jobOutput.SegmentDuration = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Status", targetDepth))
                    {
                        jobOutput.Status = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("StatusDetail", targetDepth))
                    {
                        jobOutput.StatusDetail = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Duration", targetDepth))
                    {
                        jobOutput.Duration = LongUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Width", targetDepth))
                    {
                        jobOutput.Width = IntUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Height", targetDepth))
                    {
                        jobOutput.Height = IntUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("Watermarks", targetDepth))
                    {
                        jobOutput.Watermarks = new List <JobWatermark>();
                        JobWatermarkUnmarshaller unmarshaller = JobWatermarkUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                jobOutput.Watermarks.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("AlbumArt", targetDepth))
                    {
                        jobOutput.AlbumArt = JobAlbumArtUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(jobOutput);
                }
            }


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


            int targetDepth = context.CurrentDepth;

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

                if (context.TestExpression("Key", targetDepth))
                {
                    jobOutput.Key = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("ThumbnailPattern", targetDepth))
                {
                    jobOutput.ThumbnailPattern = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Rotate", targetDepth))
                {
                    jobOutput.Rotate = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("PresetId", targetDepth))
                {
                    jobOutput.PresetId = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("SegmentDuration", targetDepth))
                {
                    jobOutput.SegmentDuration = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Status", targetDepth))
                {
                    jobOutput.Status = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("StatusDetail", targetDepth))
                {
                    jobOutput.StatusDetail = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Duration", targetDepth))
                {
                    jobOutput.Duration = LongUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Width", targetDepth))
                {
                    jobOutput.Width = IntUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Height", targetDepth))
                {
                    jobOutput.Height = IntUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Watermarks", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <JobWatermark, JobWatermarkUnmarshaller>(
                        JobWatermarkUnmarshaller.GetInstance());
                    jobOutput.Watermarks = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("AlbumArt", targetDepth))
                {
                    jobOutput.AlbumArt = JobAlbumArtUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("Composition", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Clip, ClipUnmarshaller>(
                        ClipUnmarshaller.GetInstance());
                    jobOutput.Composition = unmarshaller.Unmarshall(context);

                    continue;
                }
            }

            return(jobOutput);
        }