/// <summary> /// Decode the FaunaDB value into the type specified in the argument. /// </summary> /// <example> /// Decode(LongV.Of(10), typeof(int)) => 10 /// Decode(DoubleV.Of(3.14), typeof(double)) => 3.14 /// Decode(BooleanV.True, typeof(bool)) => true /// Decode(NullV.Instance, typeof(object)) => null /// Decode(StringV.Of("a string"), typeof(string)) => "a string" /// Decode(ArrayV.Of(1, 2), typeof(int[])) => new int[] { 1, 2 } /// Decode(ArrayV.Of(1, 2), typeof(List<int>>)) => new List<int>> { 1, 2 } /// Decode(new ByteV(1, 2), typeof(byte[])) => new byte[] { 1, 2 } /// Decode(new TimeV("2000-01-01T01:10:30.123Z"), typeof(DateTime)) => new DateTime(2000, 1, 1, 1, 10, 30, 123) /// Decode(new DateV("2001-01-01"), typeof(DateTime)) => new DateTime(2001, 1, 1) /// Decode(ObjectV.With("user_name", "john", "password", "s3cr3t"), typeof(User)) => new User("john", "s3cr3t") /// </example> /// <returns>An instance of type specified in the argument</returns> /// <param name="value">The FaunaDB value to be decoded</param> /// <param name="dstType">The type in which the value should be decoded</param> public static object Decode(Value value, Type dstType) => DecoderImpl.Decode(value, dstType);
/// <summary> /// Decode the FaunaDB value into the specified type T. /// </summary> /// <example> /// Decode<int>(LongV.Of(10)) => 10 /// Decode<double>(DoubleV.Of(3.14)) => 3.14 /// Decode<bool>(BooleanV.True) => true /// Decode<object>(NullV.Instance) => null /// Decode<string>(StringV.Of("a string")) => "a string" /// Decode<int[]>(ArrayV.Of(1, 2)) => new int[] { 1, 2 } /// Decode<List<int>>(ArrayV.Of(1, 2)) => new List<int>> { 1, 2 } /// Decode<byte[]>(new ByteV(1, 2)) => new byte[] { 1, 2 } /// Decode<DateTime>(new TimeV("2000-01-01T01:10:30.123Z")) => new DateTime(2000, 1, 1, 1, 10, 30, 123) /// Decode<DateTime>(new DateV("2001-01-01")) => new DateTime(2001, 1, 1) /// Decode<User>(ObjectV.With("user_name", "john", "password", "s3cr3t")) => new User("john", "s3cr3t") /// </example> /// <returns>An instance of type T</returns> /// <param name="value">The FaunaDB value to be decoded</param> /// <typeparam name="T">The type name in which the value should be decoded</typeparam> public static T Decode <T>(Value value) => (T)DecoderImpl.Decode(value, typeof(T));