Amazon.DynamoDBv2.DocumentModel.JsonUtils.WritePrimitive C# (CSharp) Method

WritePrimitive() private static method

private static WritePrimitive ( JsonWriter writer, DynamoDBEntryType type, object value ) : void
writer ThirdParty.Json.LitJson.JsonWriter
type DynamoDBEntryType
value object
return void
        private static void WritePrimitive(JsonWriter writer, DynamoDBEntryType type, object value)
        {
            var stringValue = value as string;

            switch (type)
            {
                case DynamoDBEntryType.Numeric:
                    writer.WriteRaw(stringValue);
                    break;
                case DynamoDBEntryType.String:
                    writer.Write(stringValue);
                    break;
                case DynamoDBEntryType.Binary:
                    var bytes = value as byte[];
                    var base64 = Convert.ToBase64String(bytes);
                    writer.Write(base64);
                    break;
                default:
                    throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                        "Unsupport DynamoDBEntryType: {0}", type));
            }
        }