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); }
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; }