Ejemplo n.º 1
0
            public static void Encode(XdrDataOutputStream stream, LedgerEntryData encodedLedgerEntryData)
            {
                stream.WriteInt((int)encodedLedgerEntryData.Discriminant.InnerValue);
                switch (encodedLedgerEntryData.Discriminant.InnerValue)
                {
                case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
                    AccountEntry.Encode(stream, encodedLedgerEntryData.Account);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
                    TrustLineEntry.Encode(stream, encodedLedgerEntryData.TrustLine);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
                    OfferEntry.Encode(stream, encodedLedgerEntryData.Offer);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.DATA:
                    DataEntry.Encode(stream, encodedLedgerEntryData.Data);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.CLAIMABLE_BALANCE:
                    ClaimableBalanceEntry.Encode(stream, encodedLedgerEntryData.ClaimableBalance);
                    break;
                }
            }
Ejemplo n.º 2
0
            public static LedgerEntryData Decode(XdrDataInputStream stream)
            {
                LedgerEntryData decodedLedgerEntryData = new LedgerEntryData();
                LedgerEntryType discriminant           = LedgerEntryType.Decode(stream);

                decodedLedgerEntryData.Discriminant = discriminant;
                switch (decodedLedgerEntryData.Discriminant.InnerValue)
                {
                case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
                    decodedLedgerEntryData.Account = AccountEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
                    decodedLedgerEntryData.TrustLine = TrustLineEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
                    decodedLedgerEntryData.Offer = OfferEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.DATA:
                    decodedLedgerEntryData.Data = DataEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.CLAIMABLE_BALANCE:
                    decodedLedgerEntryData.ClaimableBalance = ClaimableBalanceEntry.Decode(stream);
                    break;
                }
                return(decodedLedgerEntryData);
            }
        public static void Encode(XdrDataOutputStream stream, ClaimableBalanceEntry encodedClaimableBalanceEntry)
        {
            ClaimableBalanceID.Encode(stream, encodedClaimableBalanceEntry.BalanceID);
            int claimantssize = encodedClaimableBalanceEntry.Claimants.Length;

            stream.WriteInt(claimantssize);
            for (int i = 0; i < claimantssize; i++)
            {
                Claimant.Encode(stream, encodedClaimableBalanceEntry.Claimants[i]);
            }
            Asset.Encode(stream, encodedClaimableBalanceEntry.Asset);
            Int64.Encode(stream, encodedClaimableBalanceEntry.Amount);
            ClaimableBalanceEntryExt.Encode(stream, encodedClaimableBalanceEntry.Ext);
        }
        public static ClaimableBalanceEntry Decode(XdrDataInputStream stream)
        {
            ClaimableBalanceEntry decodedClaimableBalanceEntry = new ClaimableBalanceEntry();

            decodedClaimableBalanceEntry.BalanceID = ClaimableBalanceID.Decode(stream);
            int claimantssize = stream.ReadInt();

            decodedClaimableBalanceEntry.Claimants = new Claimant[claimantssize];
            for (int i = 0; i < claimantssize; i++)
            {
                decodedClaimableBalanceEntry.Claimants[i] = Claimant.Decode(stream);
            }
            decodedClaimableBalanceEntry.Asset  = Asset.Decode(stream);
            decodedClaimableBalanceEntry.Amount = Int64.Decode(stream);
            decodedClaimableBalanceEntry.Ext    = ClaimableBalanceEntryExt.Decode(stream);
            return(decodedClaimableBalanceEntry);
        }