コード例 #1
0
        public void TestMemoId()
        {
            var memo = Memo.Id(9223372036854775807L);

            Assert.AreEqual(9223372036854775807L, memo.IdValue);
            Assert.AreEqual(sdkxdr.MemoType.MemoTypeEnum.MEMO_ID, memo.ToXdr().Discriminant.InnerValue);
            Assert.AreEqual(9223372036854775807L, memo.ToXdr().Id.InnerValue);
        }
コード例 #2
0
ファイル: MemoTest.cs プロジェクト: kodlar/stellar-sdk
        public void TestMemoIDEquality()
        {
            var memo  = Memo.Id(9223372036854775807L);
            var memo2 = Memo.Id(9223372036854775807L);

            Assert.AreEqual(memo.GetHashCode(), memo2.GetHashCode());
            Assert.AreEqual(memo, memo2);
        }
コード例 #3
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            reader.DateParseHandling = DateParseHandling.None;

            var jsonObject = JObject.Load(reader);

            TransactionResponse transaction = jsonObject.ToObject <TransactionResponse>();


            var memoType = jsonObject.GetValue("memo_type").ToObject <string>();

            Memo memo;

            if (memoType.Equals("none"))
            {
                memo = Memo.None();
            }
            else
            {
                String memoValue = transaction.MemoStr;

                if (memoType.Equals("text"))
                {
                    memo = Memo.Text(memoValue);
                }
                else if (memoType.Equals("id"))
                {
                    memo = Memo.Id(long.Parse(memoValue));
                }
                else if (memoType.Equals("hash"))
                {
                    memo = Memo.Hash(Convert.FromBase64String(memoValue));
                }
                else if (memoType.Equals("return"))
                {
                    memo = Memo.ReturnHash(Convert.FromBase64String(memoValue));
                }
                else
                {
                    throw new JsonException("Unknown memo type.");
                }
            }

            transaction.Memo = memo;
            return(transaction);
        }