예제 #1
0
 public static KeySchemaUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new KeySchemaUnmarshaller();
     }
     return(instance);
 }
        public TableDescription Unmarshall(JsonUnmarshallerContext context)
        {
            TableDescription tableDescription = new TableDescription();

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

            while (context.Read())
            {
                if ((context.IsKey) && (context.CurrentDepth == targetDepth))
                {
                    context.Read();
                    context.Read();

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

                    if (context.TestExpression("KeySchema", targetDepth))
                    {
                        tableDescription.KeySchema = KeySchemaUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

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

                    if (context.TestExpression("CreationDateTime", targetDepth))
                    {
                        tableDescription.CreationDateTime = DateTimeUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("ProvisionedThroughput", targetDepth))
                    {
                        tableDescription.ProvisionedThroughput = ProvisionedThroughputDescriptionUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

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

                    if (context.TestExpression("ItemCount", targetDepth))
                    {
                        tableDescription.ItemCount = LongUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }
                }
                else if (context.IsEndElement && context.CurrentDepth <= originalDepth)
                {
                    return(tableDescription);
                }
            }


            return(tableDescription);
        }