public static int?AsIntNullable(this DynamoDBEntry entry)
        {
            if (entry is DynamoDBNull)
            {
                return(null);
            }

            return(entry.AsInt());
        }
 public static int?AsIntOrDefault(this DynamoDBEntry o)
 {
     if (o == null)
     {
         return(null);
     }
     else
     {
         return(o.AsInt());
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 public object FromEntry(DynamoDBEntry entry) => entry.AsInt();
Exemplo n.º 5
0
 public object FromEntry(DynamoDBEntry entry)
 {
     return(entry == null ? 0 : entry.AsInt());
 }
Exemplo n.º 6
0
        public static T Convert <T>(DynamoDBEntry entry)
        {
            Type type = typeof(T);

#pragma warning disable IDE0011 // Add braces
            if (type == typeof(bool))
            {
                return((T)(object)entry.AsBoolean());
            }
            if (type == typeof(byte))
            {
                return((T)(object)entry.AsByte());
            }
            if (type == typeof(byte[]))
            {
                return((T)(object)entry.AsByteArray());
            }
            if (type == typeof(char))
            {
                return((T)(object)entry.AsChar());
            }
            if (type == typeof(DateTime))
            {
                return((T)(object)entry.AsDateTime());
            }
            if (type == typeof(decimal))
            {
                return((T)(object)entry.AsDecimal());
            }
            if (type == typeof(double))
            {
                return((T)(object)entry.AsDouble());
            }
            if (type == typeof(Guid))
            {
                return((T)(object)entry.AsGuid());
            }
            if (type == typeof(int))
            {
                return((T)(object)entry.AsInt());
            }
            if (type == typeof(long))
            {
                return((T)(object)entry.AsLong());
            }
            if (type == typeof(MemoryStream))
            {
                return((T)(object)entry.AsMemoryStream());
            }
            if (type == typeof(sbyte))
            {
                return((T)(object)entry.AsSByte());
            }
            if (type == typeof(short))
            {
                return((T)(object)entry.AsShort());
            }
            if (type == typeof(float))
            {
                return((T)(object)entry.AsSingle());
            }
            if (type == typeof(string))
            {
                return((T)(object)entry.AsString());
            }
            if (type == typeof(uint))
            {
                return((T)(object)entry.AsUInt());
            }
            if (type == typeof(ulong))
            {
                return((T)(object)entry.AsULong());
            }
            if (type == typeof(ushort))
            {
                return((T)(object)entry.AsUShort());
            }
#pragma warning restore IDE0011 // Add braces
            throw new InvalidOperationException($"{type.FullName} is not supported as aggregate key in DynamoDB");
        }