/// <summary> /// Decodes specific attributes from base64 to their binary representation. /// </summary> /// <param name="document"></param> /// <param name="attributeNames"></param> public static void DecodeBase64Attributes(Document document, params string[] attributeNames) { if (attributeNames == null || attributeNames.Length == 0) { return; } var decodedValues = new Dictionary <string, DynamoDBEntry>(StringComparer.Ordinal); // Convert, but don't alter the original yet foreach (var attributeName in attributeNames) { DynamoDBEntry entry; // If an attribute is not present, do nothing if (!document.TryGetValue(attributeName, out entry)) { continue; } DynamoDBEntry decodedEntry; if (!TryDecodeBase64(entry, out decodedEntry)) { throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Unable to decode attribute {0} of type {1} in document", attributeName, entry.GetType().FullName)); } decodedValues[attributeName] = decodedEntry; } // Update document with decoded attribute values foreach (var kvp in decodedValues) { var attributeName = kvp.Key; var decodedEntry = kvp.Value; document[attributeName] = decodedEntry; } }