public static JobWatermarkUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new JobWatermarkUnmarshaller();
     }
     return(instance);
 }
        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);
        }
Esempio n. 3
0
        public JobOutput Unmarshall(JsonUnmarshallerContext context)
        {
            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;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(jobOutput);
                }
            }


            return(jobOutput);
        }
Esempio n. 4
0
        public JobOutput Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            JobOutput jobOutput = new JobOutput();



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


            return(jobOutput);
        }