public async Task List() { Console.WriteLine("Entering List"); var description = await DescribeTable(); Console.WriteLine($"Table name: {description.TableName}" + " " + $"Table status: {description.TableStatus}"); Table QTable = Table.LoadTable(client, ClientTableName); //get the RequestQ items for the ClientGuid ScanFilter scanFilter = new ScanFilter(); scanFilter.AddCondition("ClientID", ScanOperator.GreaterThan, " "); ScanOperationConfig config = new ScanOperationConfig() { Filter = scanFilter, }; Search search = QTable.Scan(scanFilter); List <Document> allItems = await search.GetRemainingAsync(); Console.WriteLine("================================================================================"); foreach (Document doc in allItems) { foreach (string itemkey in doc.Keys) { DynamoDBEntry dbEntry = doc[itemkey]; if (itemkey == "ClientID") { string val = dbEntry.AsString(); Console.WriteLine("ClientID: " + val); } if (itemkey == "ClientGuid") { string val = dbEntry.AsString(); Console.WriteLine("ClientGuid: " + val); } if (itemkey == "ActiveStatus") { bool val = dbEntry.AsBoolean(); Console.WriteLine("ActiveStatus: " + val); } if (itemkey == "secret") { string val = dbEntry.AsString(); Console.WriteLine("secret: " + val); } if (itemkey == "amazn_link_time") { string val = dbEntry.AsString(); Console.WriteLine("amazn_link_time: " + val); } if (itemkey == "Appliance") { int i = 0; foreach (string device in dbEntry.AsListOfString()) { Console.WriteLine("Appliance(" + i + "): " + device); i++; } } }// end foreach key Console.WriteLine("================================================================================"); } return; }
public object FromEntry(DynamoDBEntry entry) { string valueAsString = entry.AsString(); TEnum valueAsEnum = (TEnum)Enum.Parse(typeof(TEnum), valueAsString); return(valueAsEnum); }
public object FromEntry(DynamoDBEntry entry) { var str = entry.AsString(); var list = string.IsNullOrWhiteSpace(str) ? new List <int>() : str.Split(',').Select(int.Parse).ToList(); return(list); }
public object FromEntry(DynamoDBEntry entry) { if (entry == null) { return(null); } var valueString = entry.AsString(); return((TEnum)Enum.Parse(typeof(TEnum), valueString)); }
public object FromEntry(DynamoDBEntry entry) { if (entry is DynamoDBNull) { return(new ZonedDateTime?()); } var s = entry.AsString(); var res = pattern.Parse(s); return(res.GetValueOrThrow()); }
public static string AsStringOrDefault(this DynamoDBEntry o) { if (o == null) { return(null); } else { return(o.AsString()); } }
public object FromEntry(DynamoDBEntry entry) { var value = entry.AsString(); if (DateTime.TryParse(value, out var date)) { return(date); } return(default(DateTime)); }
private static string GetValue(DynamoDBEntry attributeValue) { if (attributeValue is null) { return(null); } var value = attributeValue.AsString(); return(value); }
public object FromEntry(DynamoDBEntry entry) { var dateTime = entry?.AsString(); var returnValue = DateTime.SpecifyKind(DateTime.MinValue, DateTimeKind.Utc).Date; if (DateTime.TryParseExact(dateTime, "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime value)) { returnValue = DateTime.SpecifyKind(value.Date, DateTimeKind.Utc).Date; } return(returnValue); }
public void TestEnumConverterTo() { // ARRANGE DashboardEventStatus status = DashboardEventStatus.BLUE; EnumConverter <DashboardEventStatus> converter = new DDBConverters.EnumConverter <DashboardEventStatus>(); // ACT DynamoDBEntry entry = converter.ToEntry(status); // ASSERT Assert.Equal("BLUE", entry.AsString()); }
public object FromEntry(DynamoDBEntry entry) { if (entry is null) { return(null); } if (entry is DynamoDBBool) { return(entry.AsBoolean()); } return(bool.Parse(entry.AsString())); }
public void TestDateTimeConverterTo() { // ARRANGE long time = 1525914401; DateTime dt = ServiceUtilities.ConvertFromUnixTimestamp(time); TimestampConverter converter = new TimestampConverter(); // ACT DynamoDBEntry data = converter.ToEntry(time); // ASSERT Assert.Equal(dt, DateTime.Parse(data.AsString()).ToUniversalTime()); }
/// <summary> /// Converts the <c>entry</c> to <see cref="DateTime"/>. /// </summary> /// <param name="entry">The entry to convert.</param> /// <returns>The date time of the entry.</returns> public object FromEntry(DynamoDBEntry entry) { var entryString = entry.AsString(); if (string.IsNullOrEmpty(entryString)) { return(null); } else { return(DateTime.ParseExact(entryString, "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind)); } }
public object FromEntry(DynamoDBEntry entry) { var primitive = entry as Primitive; if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value)) { throw new ArgumentOutOfRangeException(); } var value = JsonSerializer.Deserialize <MoneyDTO>(entry.AsString(), JsonSerialisationOptions.Options); var name = new Money((int)value.Amount, value.Currency); return(name); }
public void TestDictionaryConverterTo() { // ARRANGE Dictionary <string, long> dict = new Dictionary <string, long>() { { "1", 2 }, { "3", 4 } }; DictionaryConverter <string, long> converter = new DictionaryConverter <string, long>(); // ACT DynamoDBEntry entry = converter.ToEntry(dict); // ASSERT Assert.Equal("{\"1\":2,\"3\":4}", entry.AsString()); }
public object FromEntry(DynamoDBEntry entry) { var primitive = entry as Primitive; if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value)) { throw new ArgumentOutOfRangeException(); } var value = JObject.Parse(entry.AsString()); var name = new Money((int)value[Amount], (string)value[Currency]); return(name); }
public object FromEntry(DynamoDBEntry entry) { string valueAsString = entry.AsString(); if (String.IsNullOrEmpty(valueAsString)) { return(default(TEnum)); } if (Enum.TryParse <TEnum>(valueAsString, true, out TEnum valueAsEnum) && Enum.IsDefined(typeof(TEnum), valueAsEnum)) { return(valueAsEnum); } return(default(TEnum)); }
public object FromEntry(DynamoDBEntry entry) { var dateTime = entry?.AsString(); if (string.IsNullOrEmpty(dateTime)) { return(null); } if (!DateTime.TryParse(dateTime, out DateTime value)) { throw new ArgumentException("The entry parameter is not a valid DateTime value.", nameof(entry)); } return(value); }
public object FromEntry(DynamoDBEntry entry) { var dateTime = entry?.AsString(); if (string.IsNullOrEmpty(dateTime)) { return(null); } try { return(TimeZoneInfo.ConvertTime(DateTimeOffset.Parse(dateTime), TZConvert.GetTimeZoneInfo("Tokyo Standard Time")).DateTime); } catch { return(null); } }
private static void DynamoDbEntryAsString(StringBuilder sb, DynamoDBEntry entry) { var list = entry as PrimitiveList; if (list == null) { sb.Append(entry == null ? "NULL" : entry.AsString()); return; } string s = list.AsListOfPrimitive().Aggregate ( string.Empty, (c, p) => c == string.Empty ? p.AsString() : c + "," + p.AsString() ); sb.Append("("); sb.Append(s); sb.Append(")"); }
public object FromEntry(DynamoDBEntry entry) { Primitive primitive = entry as Primitive; if (primitive == null || !(primitive.Value is String) || string.IsNullOrEmpty((string)primitive.Value)) { throw new ArgumentOutOfRangeException(); } string entryString = entry.AsString(); foreach (KudosStatus status in Enum.GetValues <KudosStatus>()) { if (status.ToString() == entryString) { return(status); } } return(KudosStatus.Unknown); }
public static object AsType(this DynamoDBEntry entry, Type type) { if (type == stringType) { return(entry.AsString()); } else if (type == intType) { return(entry.AsInt()); } else if (type == boolType) { return(entry.AsBoolean()); } else if (type == longType) { return(entry.AsLong()); } else if (type == dateTimeType) { return(entry.AsDateTime()); } else if (type == doubleType) { return(entry.AsDouble()); } else if (type == floatType) { return(entry.AsSingle()); } else if (type == listOfStringType) { return(entry.AsListOfString()); } else if (type == listOfByteArrayType) { return(entry.AsListOfString()); } return(null); }
/// <inheritdoc/> public object FromEntry(DynamoDBEntry entry) => Enum.Parse <TEnum>(entry.AsString());
public object FromEntry(DynamoDBEntry entry) { string dateTimeString = entry.AsString(); return(DateTime.Parse(dateTimeString)); }
public object FromEntry(DynamoDBEntry entry) { return(new Guid(entry.AsString())); }
public object FromEntry(DynamoDBEntry entry) { return(Enum.Parse(typeof(Stars), entry.AsString())); }
public object FromEntry(DynamoDBEntry entry) { return(DateTimeOffset.ParseExact(entry.AsString(), "o", null)); }
public object?FromEntry(DynamoDBEntry entry) { string json = entry.AsString(); return(Serializer.Deserialize(json, this.type)); }
public object FromEntry(DynamoDBEntry entry) { var dateTime = entry.AsString(); return(DateTime.ParseExact(dateTime, "O", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal)); }
/// <summary> /// Converts the <c>entry</c> to <see cref="DateTime"/>. /// </summary> /// <param name="entry">The entry to convert.</param> /// <returns>The date time of the entry.</returns> public object FromEntry(DynamoDBEntry entry) { return(DateTime.ParseExact(entry.AsString(), "o", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind)); }