コード例 #1
0
 /// <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&lt;int&gt;&gt;)) => new List&lt;int&gt;&gt; { 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);
コード例 #2
0
 /// <summary>
 /// Decode the FaunaDB value into the specified type T.
 /// </summary>
 /// <example>
 /// Decode&lt;int&gt;(LongV.Of(10)) => 10
 /// Decode&lt;double&gt;(DoubleV.Of(3.14)) => 3.14
 /// Decode&lt;bool&gt;(BooleanV.True) => true
 /// Decode&lt;object&gt;(NullV.Instance) => null
 /// Decode&lt;string&gt;(StringV.Of("a string")) => "a string"
 /// Decode&lt;int[]&gt;(ArrayV.Of(1, 2)) => new int[] { 1, 2 }
 /// Decode&lt;List&lt;int&gt;&gt;(ArrayV.Of(1, 2)) => new List&lt;int&gt;&gt; { 1, 2 }
 /// Decode&lt;byte[]&gt;(new ByteV(1, 2)) => new byte[] { 1, 2 }
 /// Decode&lt;DateTime&gt;(new TimeV("2000-01-01T01:10:30.123Z")) => new DateTime(2000, 1, 1, 1, 10, 30, 123)
 /// Decode&lt;DateTime&gt;(new DateV("2001-01-01")) => new DateTime(2001, 1, 1)
 /// Decode&lt;User&gt;(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));