public static ApplicationUnmarshaller GetInstance() { if (instance == null) { instance = new ApplicationUnmarshaller(); } return(instance); }
public Cluster Unmarshall(JsonUnmarshallerContext context) { context.Read(); if (context.CurrentTokenType == JsonToken.Null) { return(null); } Cluster cluster = new Cluster(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("Id", targetDepth)) { cluster.Id = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { cluster.Name = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Status", targetDepth)) { cluster.Status = ClusterStatusUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Ec2InstanceAttributes", targetDepth)) { cluster.Ec2InstanceAttributes = Ec2InstanceAttributesUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("LogUri", targetDepth)) { cluster.LogUri = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("RequestedAmiVersion", targetDepth)) { cluster.RequestedAmiVersion = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("RunningAmiVersion", targetDepth)) { cluster.RunningAmiVersion = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("AutoTerminate", targetDepth)) { cluster.AutoTerminate = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("TerminationProtected", targetDepth)) { cluster.TerminationProtected = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("VisibleToAllUsers", targetDepth)) { cluster.VisibleToAllUsers = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Applications", targetDepth)) { var unmarshaller = new ListUnmarshaller <Application, ApplicationUnmarshaller>( ApplicationUnmarshaller.GetInstance()); cluster.Applications = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Tags", targetDepth)) { var unmarshaller = new ListUnmarshaller <Tag, TagUnmarshaller>( TagUnmarshaller.GetInstance()); cluster.Tags = unmarshaller.Unmarshall(context); continue; } } return(cluster); }
public Cluster Unmarshall(JsonUnmarshallerContext context) { if (context.CurrentTokenType == JsonToken.Null) { return(null); } Cluster cluster = new Cluster(); int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("Id", targetDepth)) { context.Read(); cluster.Id = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { context.Read(); cluster.Name = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Status", targetDepth)) { context.Read(); cluster.Status = ClusterStatusUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Ec2InstanceAttributes", targetDepth)) { context.Read(); cluster.Ec2InstanceAttributes = Ec2InstanceAttributesUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("LogUri", targetDepth)) { context.Read(); cluster.LogUri = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("RequestedAmiVersion", targetDepth)) { context.Read(); cluster.RequestedAmiVersion = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("RunningAmiVersion", targetDepth)) { context.Read(); cluster.RunningAmiVersion = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("AutoTerminate", targetDepth)) { context.Read(); cluster.AutoTerminate = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("TerminationProtected", targetDepth)) { context.Read(); cluster.TerminationProtected = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("VisibleToAllUsers", targetDepth)) { context.Read(); cluster.VisibleToAllUsers = BoolUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.TestExpression("Applications", targetDepth)) { context.Read(); if (context.CurrentTokenType == JsonToken.Null) { cluster.Applications = null; continue; } cluster.Applications = new List <Application>(); ApplicationUnmarshaller unmarshaller = ApplicationUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } cluster.Applications.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.TestExpression("Tags", targetDepth)) { context.Read(); if (context.CurrentTokenType == JsonToken.Null) { cluster.Tags = null; continue; } cluster.Tags = new List <Tag>(); TagUnmarshaller unmarshaller = TagUnmarshaller.GetInstance(); while (context.Read()) { JsonToken token = context.CurrentTokenType; if (token == JsonToken.ArrayStart) { continue; } if (token == JsonToken.ArrayEnd) { break; } cluster.Tags.Add(unmarshaller.Unmarshall(context)); } continue; } if (context.CurrentDepth <= originalDepth) { return(cluster); } } return(cluster); }