Пример #1
0
        public PipelineObject Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            PipelineObject pipelineObject = new PipelineObject();



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

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

                if (context.TestExpression("name", targetDepth))
                {
                    context.Read();
                    pipelineObject.Name = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("fields", targetDepth))
                {
                    context.Read();
                    pipelineObject.Fields = new List <Field>();
                    FieldUnmarshaller unmarshaller = FieldUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        pipelineObject.Fields.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

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


            return(pipelineObject);
        }
Пример #2
0
        public PipelineDescription Unmarshall(JsonUnmarshallerContext context)
        {
            PipelineDescription pipelineDescription = new PipelineDescription();
          pipelineDescription.Fields = 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("PipelineId", targetDepth))
              {
                pipelineDescription.PipelineId = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
              if (context.TestExpression("Name", targetDepth))
              {
                pipelineDescription.Name = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
              if (context.TestExpression("Fields", targetDepth))
              {
                pipelineDescription.Fields = new List<Field>();
                        FieldUnmarshaller unmarshaller = FieldUnmarshaller.GetInstance();
                while (context.Read())
                {
                  if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                  {
                     pipelineDescription.Fields.Add(unmarshaller.Unmarshall(context));
                  }
                  else if (context.IsEndArray)
                  {
                    break;
                  }
                }
                continue;
              }
  
              if (context.TestExpression("Description", targetDepth))
              {
                pipelineDescription.Description = StringUnmarshaller.GetInstance().Unmarshall(context);
                continue;
              }
  
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return pipelineDescription;
                }
            }
          

            return pipelineDescription;
        }
Пример #3
0
 public static FieldUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new FieldUnmarshaller();
     }
     return(instance);
 }
        public PipelineDescription Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            PipelineDescription pipelineDescription = new PipelineDescription();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("pipelineId", targetDepth))
                {
                    pipelineDescription.PipelineId = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("name", targetDepth))
                {
                    pipelineDescription.Name = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("fields", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Field, FieldUnmarshaller>(
                        FieldUnmarshaller.GetInstance());
                    pipelineDescription.Fields = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("description", targetDepth))
                {
                    pipelineDescription.Description = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }
            }

            return(pipelineDescription);
        }