コード例 #1
0
 public static ProjectionUnmarshaller GetInstance()
 {
     if (instance == null)
     {
         instance = new ProjectionUnmarshaller();
     }
     return(instance);
 }
コード例 #2
0
        public LocalSecondaryIndexDescription Unmarshall(JsonUnmarshallerContext context)
        {
            context.Read();
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }
            LocalSecondaryIndexDescription localSecondaryIndexDescription = new LocalSecondaryIndexDescription();


            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("IndexName", targetDepth))
                {
                    localSecondaryIndexDescription.IndexName = StringUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

                if (context.TestExpression("KeySchema", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <KeySchemaElement, KeySchemaElementUnmarshaller>(
                        KeySchemaElementUnmarshaller.GetInstance());
                    localSecondaryIndexDescription.KeySchema = unmarshaller.Unmarshall(context);

                    continue;
                }

                if (context.TestExpression("Projection", targetDepth))
                {
                    localSecondaryIndexDescription.Projection = ProjectionUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

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

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

            return(localSecondaryIndexDescription);
        }
コード例 #3
0
        public GlobalSecondaryIndexDescription Unmarshall(JsonUnmarshallerContext context)
        {
            if (context.CurrentTokenType == JsonToken.Null)
            {
                return(null);
            }

            GlobalSecondaryIndexDescription globalSecondaryIndexDescription = new GlobalSecondaryIndexDescription();



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

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

                if (context.TestExpression("KeySchema", targetDepth))
                {
                    context.Read();
                    globalSecondaryIndexDescription.KeySchema = new List <KeySchemaElement>();
                    if (context.CurrentTokenType == JsonToken.Null)
                    {
                        continue;
                    }
                    KeySchemaElementUnmarshaller unmarshaller = KeySchemaElementUnmarshaller.GetInstance();
                    while (context.Read())
                    {
                        JsonToken token = context.CurrentTokenType;
                        if (token == JsonToken.ArrayStart)
                        {
                            continue;
                        }
                        if (token == JsonToken.ArrayEnd)
                        {
                            break;
                        }
                        globalSecondaryIndexDescription.KeySchema.Add(unmarshaller.Unmarshall(context));
                    }
                    continue;
                }

                if (context.TestExpression("Projection", targetDepth))
                {
                    context.Read();
                    globalSecondaryIndexDescription.Projection = ProjectionUnmarshaller.GetInstance().Unmarshall(context);
                    continue;
                }

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

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

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

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

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


            return(globalSecondaryIndexDescription);
        }
        public LocalSecondaryIndexDescription Unmarshall(JsonUnmarshallerContext context)
        {
            LocalSecondaryIndexDescription localSecondaryIndexDescription = new LocalSecondaryIndexDescription();

            localSecondaryIndexDescription.KeySchema = 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("IndexName", targetDepth))
                    {
                        localSecondaryIndexDescription.IndexName = StringUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

                    if (context.TestExpression("KeySchema", targetDepth))
                    {
                        localSecondaryIndexDescription.KeySchema = new List <KeySchemaElement>();
                        KeySchemaElementUnmarshaller unmarshaller = KeySchemaElementUnmarshaller.GetInstance();
                        while (context.Read())
                        {
                            if ((context.IsArrayElement) && (context.CurrentDepth == targetDepth))
                            {
                                localSecondaryIndexDescription.KeySchema.Add(unmarshaller.Unmarshall(context));
                            }
                            else if (context.IsEndArray)
                            {
                                break;
                            }
                        }
                        continue;
                    }

                    if (context.TestExpression("Projection", targetDepth))
                    {
                        localSecondaryIndexDescription.Projection = ProjectionUnmarshaller.GetInstance().Unmarshall(context);
                        continue;
                    }

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

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


            return(localSecondaryIndexDescription);
        }