public static DecoratedSignature Decode(IByteReader stream)
 {
     DecoratedSignature decodedDecoratedSignature = new DecoratedSignature();
     decodedDecoratedSignature.Hint = SignatureHint.Decode(stream);
     decodedDecoratedSignature.Signature = Signature.Decode(stream);
     return decodedDecoratedSignature;
 }
Esempio n. 2
0
 public static Value Decode(IByteReader stream)
 {
     Value decodedValue = new Value();
       int Valuesize = XdrEncoding.DecodeInt32(stream);
       decodedValue.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Valuesize);
     return decodedValue;
 }
Esempio n. 3
0
 public static Error Decode(IByteReader stream)
 {
     Error decodedError = new Error();
     decodedError.Code = ErrorCode.Decode(stream);
     decodedError.Msg = XdrEncoding.ReadString(stream);
     return decodedError;
 }
 public static PaymentOp Decode(IByteReader stream) {
   PaymentOp decodedPaymentOp = new PaymentOp();
   decodedPaymentOp.Destination = AccountID.Decode(stream);
   decodedPaymentOp.Asset = Asset.Decode(stream);
   decodedPaymentOp.Amount = Int64.Decode(stream);
   return decodedPaymentOp;
 }
 public static HmacSha256Mac Decode(IByteReader stream)
 {
     HmacSha256Mac decodedHmacSha256Mac = new HmacSha256Mac();
     int macsize = 32;
     decodedHmacSha256Mac.Mac = XdrEncoding.ReadFixOpaque(stream, (uint)macsize);
     return decodedHmacSha256Mac;
 }
Esempio n. 6
0
		//public int getMaxOffset() { return MaxOffset; }



		/**
		 * checks whether the binary file specified by targetFile is compliant
		 * with this byte sequence
		 *
		 * @param targetFile   The binary file to be identified
		 */
		public bool isFileCompliant(IByteReader targetFile)
		{
			//System.out.println("Looking at new byte sequence with reference "+Reference);
			//initialise variables and start with the file marker at the beginning of the file
			bool isCompliant = true;
			bool reverseOrder = (string.Compare(getReference(), "EOFoffset", true) == 0) ? true : false; //(getReference().equalsIgnoreCase("EOFoffset")) ? true : false;
			int ssLoopStart = reverseOrder ? getNumSubSequences() - 1 : 0;
			int ssLoopEnd = reverseOrder ? -1 : getNumSubSequences();
			int searchDirection = reverseOrder ? -1 : 1;
			if (reverseOrder)
			{
				targetFile.SetFileMarker(targetFile.GetNumberOfBytes() - 1L);
			}
			else
			{
				targetFile.SetFileMarker(0L);
			}

			//check whether each subsequence in turn is compliant
			for (int iSS = ssLoopStart; (searchDirection * iSS < searchDirection * ssLoopEnd) & isCompliant; iSS += searchDirection)
			{
				bool isFixedStart = ((string.Compare(getReference(), "EOFoffset", true) == 0) || (string.Compare(getReference(), "BOFoffset", true) == 0)) ? true : false; //getReference().equalsIgnoreCase("EOFoffset") || getReference().equalsIgnoreCase("BOFoffset");
				if ((iSS == ssLoopStart) && (isFixedStart))
				{
					isCompliant = getSubSequence(iSS).isFoundAtStartOfFile(targetFile, reverseOrder, bigEndian); //, MaxOffset);
				}
				else
				{
					isCompliant = getSubSequence(iSS).isFoundAfterFileMarker(targetFile, reverseOrder, bigEndian);
				}
			}
			return isCompliant;
		}
 public static CreateAccountOp Decode(IByteReader stream)
 {
     CreateAccountOp decodedCreateAccountOp = new CreateAccountOp();
     decodedCreateAccountOp.Destination = AccountID.Decode(stream);
     decodedCreateAccountOp.StartingBalance = Int64.Decode(stream);
     return decodedCreateAccountOp;
 }
Esempio n. 8
0
 public static Signature Decode(IByteReader stream)
 {
     Signature decodedSignature = new Signature();
       int Signaturesize = XdrEncoding.DecodeInt32(stream);
       decodedSignature.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Signaturesize);
     return decodedSignature;
 }
 public static LedgerEntry Decode(IByteReader stream) {
   LedgerEntry decodedLedgerEntry = new LedgerEntry();
   decodedLedgerEntry.LastModifiedLedgerSeq = Uint32.Decode(stream);
   decodedLedgerEntry.Data = LedgerEntryData.Decode(stream);
   decodedLedgerEntry.Ext = LedgerEntryExt.Decode(stream);
   return decodedLedgerEntry;
 }
Esempio n. 10
0
 public static Hash Decode(IByteReader stream)
 {
     Hash decodedHash = new Hash();
       int Hashsize = 32;
       decodedHash.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Hashsize);
     return decodedHash;
 }
 public static AuthenticatedMessageV0 Decode(IByteReader stream) {
   AuthenticatedMessageV0 decodedAuthenticatedMessageV0 = new AuthenticatedMessageV0();
   decodedAuthenticatedMessageV0.Sequence = Uint64.Decode(stream);
   decodedAuthenticatedMessageV0.Message = StellarMessage.Decode(stream);
   decodedAuthenticatedMessageV0.Mac = HmacSha256Mac.Decode(stream);
   return decodedAuthenticatedMessageV0;
 }
 public static Curve25519Public Decode(IByteReader stream)
 {
     Curve25519Public decodedCurve25519Public = new Curve25519Public();
     int keysize = 32;
     decodedCurve25519Public.Key = XdrEncoding.ReadFixOpaque(stream, (uint)keysize);
     return decodedCurve25519Public;
 }
 public static Curve25519Secret Decode(IByteReader stream)
 {
     Curve25519Secret decodedCurve25519Secret = new Curve25519Secret();
     int keysize = 32;
     decodedCurve25519Secret.Key = XdrEncoding.ReadFixOpaque(stream, (uint)keysize);
     return decodedCurve25519Secret;
 }
 public static LedgerHeaderHistoryEntry Decode(IByteReader stream) {
   LedgerHeaderHistoryEntry decodedLedgerHeaderHistoryEntry = new LedgerHeaderHistoryEntry();
   decodedLedgerHeaderHistoryEntry.Hash = Hash.Decode(stream);
   decodedLedgerHeaderHistoryEntry.Header = LedgerHeader.Decode(stream);
   decodedLedgerHeaderHistoryEntry.Ext = LedgerHeaderHistoryEntryExt.Decode(stream);
   return decodedLedgerHeaderHistoryEntry;
 }
 public static AuthCert Decode(IByteReader stream) {
   AuthCert decodedAuthCert = new AuthCert();
   decodedAuthCert.Pubkey = Curve25519Public.Decode(stream);
   decodedAuthCert.Expiration = Uint64.Decode(stream);
   decodedAuthCert.Sig = Signature.Decode(stream);
   return decodedAuthCert;
 }
Esempio n. 16
0
 public static Thresholds Decode(IByteReader stream)
 {
     Thresholds decodedThresholds = new Thresholds();
       int Thresholdssize = 4;
       decodedThresholds.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Thresholdssize);
     return decodedThresholds;
 }
 public static InflationPayout Decode(IByteReader stream)
 {
     InflationPayout decodedInflationPayout = new InflationPayout();
     decodedInflationPayout.Destination = AccountID.Decode(stream);
     decodedInflationPayout.Amount = Int64.Decode(stream);
     return decodedInflationPayout;
 }
 public static TransactionHistoryResultEntry Decode(IByteReader stream) {
   TransactionHistoryResultEntry decodedTransactionHistoryResultEntry = new TransactionHistoryResultEntry();
   decodedTransactionHistoryResultEntry.LedgerSeq = Uint32.Decode(stream);
   decodedTransactionHistoryResultEntry.TxResultSet = TransactionResultSet.Decode(stream);
   decodedTransactionHistoryResultEntry.Ext = TransactionHistoryResultEntryExt.Decode(stream);
   return decodedTransactionHistoryResultEntry;
 }
 public static SCPStatement Decode(IByteReader stream) {
   SCPStatement decodedSCPStatement = new SCPStatement();
   decodedSCPStatement.NodeID = NodeID.Decode(stream);
   decodedSCPStatement.SlotIndex = Uint64.Decode(stream);
   decodedSCPStatement.Pledges = SCPStatementPledges.Decode(stream);
   return decodedSCPStatement;
 }
 public static TransactionResult Decode(IByteReader stream) {
   TransactionResult decodedTransactionResult = new TransactionResult();
   decodedTransactionResult.FeeCharged = Int64.Decode(stream);
   decodedTransactionResult.Result = TransactionResultResult.Decode(stream);
   decodedTransactionResult.Ext = TransactionResultExt.Decode(stream);
   return decodedTransactionResult;
 }
 public static PeerAddress Decode(IByteReader stream) {
   PeerAddress decodedPeerAddress = new PeerAddress();
   decodedPeerAddress.Ip = PeerAddressIp.Decode(stream);
   decodedPeerAddress.Port = Uint32.Decode(stream);
   decodedPeerAddress.NumFailures = Uint32.Decode(stream);
   return decodedPeerAddress;
 }
 public static TransactionResultPair Decode(IByteReader stream)
 {
     TransactionResultPair decodedTransactionResultPair = new TransactionResultPair();
     decodedTransactionResultPair.TransactionHash = Hash.Decode(stream);
     decodedTransactionResultPair.Result = TransactionResult.Decode(stream);
     return decodedTransactionResultPair;
 }
Esempio n. 23
0
 public static Price Decode(IByteReader stream)
 {
     Price decodedPrice = new Price();
     decodedPrice.N = Int32.Decode(stream);
     decodedPrice.D = Int32.Decode(stream);
     return decodedPrice;
 }
 public static SimplePaymentResult Decode(IByteReader stream) {
   SimplePaymentResult decodedSimplePaymentResult = new SimplePaymentResult();
   decodedSimplePaymentResult.Destination = AccountID.Decode(stream);
   decodedSimplePaymentResult.Asset = Asset.Decode(stream);
   decodedSimplePaymentResult.Amount = Int64.Decode(stream);
   return decodedSimplePaymentResult;
 }
Esempio n. 25
0
 public static SignatureHint Decode(IByteReader stream)
 {
     SignatureHint decodedSignatureHint = new SignatureHint();
       int SignatureHintsize = 4;
       decodedSignatureHint.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)SignatureHintsize);
     return decodedSignatureHint;
 }
Esempio n. 26
0
 public static Uint256 Decode(IByteReader stream)
 {
     Uint256 decodedUint256 = new Uint256();
       int uint256size = 32;
       decodedUint256.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)uint256size);
     return decodedUint256;
 }
 public static AllowTrustOp Decode(IByteReader stream) {
   AllowTrustOp decodedAllowTrustOp = new AllowTrustOp();
   decodedAllowTrustOp.Trustor = AccountID.Decode(stream);
   decodedAllowTrustOp.Asset = AllowTrustOpAsset.Decode(stream);
   decodedAllowTrustOp.Authorize = XdrEncoding.ReadBool(stream);
   return decodedAllowTrustOp;
 }
 public static AssetAlphaNum4 Decode(IByteReader stream) {
   AssetAlphaNum4 decodedAssetAlphaNum4 = new AssetAlphaNum4();
   int assetCodesize = 4;
   decodedAssetAlphaNum4.AssetCode = XdrEncoding.ReadFixOpaque(stream, (uint)assetCodesize);
   decodedAssetAlphaNum4.Issuer = AccountID.Decode(stream);
   return decodedAssetAlphaNum4;
 }
  public static TrustLineFlags Decode(IByteReader stream) {
    int value = XdrEncoding.DecodeInt32(stream);
    switch (value) {
      case 1: return Create(TrustLineFlagsEnum.AUTHORIZED_FLAG);
			default:
			  throw new System.Exception("Unknown enum value: " + value);
		  }
		}
  public static OfferEntryFlags Decode(IByteReader stream) {
    int value = XdrEncoding.DecodeInt32(stream);
    switch (value) {
      case 1: return Create(OfferEntryFlagsEnum.PASSIVE_FLAG);
			default:
			  throw new System.Exception("Unknown enum value: " + value);
		  }
		}
        private byte[] fetchResponse()
        {
            byte[]      response   = m_udpClient.Receive(ref m_endPoint);
            IByteReader byteReader = Common.Helper.GetByteReader(response);

            if (byteReader.GetLong().Equals(Common.Constants.SimpleResponseHeader))
            {
                return(byteReader.GetRemaining());
            }
            else
            {
                throw new NotImplementedException("Mulitpacket Responses are not yet supported.");
            }
        }
        public static TransactionEnvelope Decode(IByteReader stream)
        {
            TransactionEnvelope decodedTransactionEnvelope = new TransactionEnvelope();

            decodedTransactionEnvelope.Tx = Transaction.Decode(stream);
            int signaturessize = XdrEncoding.DecodeInt32(stream);

            decodedTransactionEnvelope.Signatures = new DecoratedSignature[signaturessize];
            for (int i = 0; i < signaturessize; i++)
            {
                decodedTransactionEnvelope.Signatures[i] = DecoratedSignature.Decode(stream);
            }
            return(decodedTransactionEnvelope);
        }
Esempio n. 33
0
        public static InflationResultCode Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(InflationResultCodeEnum.INFLATION_SUCCESS));

            case -1: return(Create(InflationResultCodeEnum.INFLATION_NOT_TIME));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 34
0
 public void ReadFrom(IByteReader reader)
 {
     reader.ReadLong();
     FileName = reader.ReadUnicodeString();
     Name     = reader.ReadUnicodeString();
     reader.ReadByte();
     reader.ReadInt();
     AccountId    = reader.ReadLong();
     CharacterId  = reader.ReadLong();
     Author       = reader.ReadUnicodeString();
     CreationTime = reader.ReadLong();
     Url          = reader.ReadUnicodeString();
     reader.ReadByte();
 }
Esempio n. 35
0
        public static OfferEntry Decode(IByteReader stream)
        {
            OfferEntry decodedOfferEntry = new OfferEntry();

            decodedOfferEntry.SellerID = AccountID.Decode(stream);
            decodedOfferEntry.OfferID  = Uint64.Decode(stream);
            decodedOfferEntry.Selling  = Asset.Decode(stream);
            decodedOfferEntry.Buying   = Asset.Decode(stream);
            decodedOfferEntry.Amount   = Int64.Decode(stream);
            decodedOfferEntry.Price    = Price.Decode(stream);
            decodedOfferEntry.Flags    = Uint32.Decode(stream);
            decodedOfferEntry.Ext      = OfferEntryExt.Decode(stream);
            return(decodedOfferEntry);
        }
        public static LedgerSCPMessages Decode(IByteReader stream)
        {
            LedgerSCPMessages decodedLedgerSCPMessages = new LedgerSCPMessages();

            decodedLedgerSCPMessages.LedgerSeq = Uint32.Decode(stream);
            int messagessize = XdrEncoding.DecodeInt32(stream);

            decodedLedgerSCPMessages.Messages = new SCPEnvelope[messagessize];
            for (int i = 0; i < messagessize; i++)
            {
                decodedLedgerSCPMessages.Messages[i] = SCPEnvelope.Decode(stream);
            }
            return(decodedLedgerSCPMessages);
        }
Esempio n. 37
0
        public static IPAddrType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(IPAddrTypeEnum.IPv4));

            case 1: return(Create(IPAddrTypeEnum.IPv6));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 38
0
        public static BucketEntryType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(BucketEntryTypeEnum.LIVEENTRY));

            case 1: return(Create(BucketEntryTypeEnum.DEADENTRY));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 39
0
    public override void Handle(T session, IByteReader packet)
    {
        byte unknown = packet.ReadByte();

        if (unknown != 0)
        {
            return;
        }

        var type = packet.Read <Type>();

        switch (type)
        {
        case Type.Log:
            var    builder = new StringBuilder();
            string message = packet.ReadUnicodeString();
            builder.Append(message);
            if (message.Contains("exception"))
            {
                // Read remaining string
                string debug = packet.ReadUnicodeString();
                logger.LogError("[{Message}] {Debug}", message, debug);

                session.OnError?.Invoke(session, debug);
                return;
            }
            else
            {
                message = packet.ReadUnicodeString();
                builder.Append(message);
            }

            logger.LogInformation("Client Log: {Builder}", builder);
            break;

        case Type.Metric:
            byte count = packet.ReadByte();
            for (byte i = 0; i < count; i++)
            {
                packet.ReadString();    // StatisticType
                packet.Read <float>();  // Average
                packet.Read <float>();  // Standard Deviation
                packet.Read <int>();    // Data Points
                packet.Read <float>();  // Min
                packet.Read <float>();  // Max
            }
            break;
        }
    }
Esempio n. 40
0
   // <include file='../../docs.xml'
   // path='docs/doc[@name="M:PeterO.Cbor.CharacterReader.#ctor(System.IO.Stream,System.Int32,System.Boolean,System.Boolean)"]/*'/>
   public CharacterReader(
 Stream stream,
 int mode,
 bool errorThrow,
 bool dontSkipUtf8Bom) {
     if (stream == null) {
       throw new ArgumentNullException("stream");
     }
     this.stream = new WrappedStream(stream);
     this.mode = mode;
     this.errorThrow = errorThrow;
     this.dontSkipUtf8Bom = dontSkipUtf8Bom;
     this.str = String.Empty;
     this.strLength = -1;
   }
Esempio n. 41
0
        public static ManageDataResult Decode(IByteReader stream)
        {
            ManageDataResult decodedManageDataResult = new ManageDataResult();

            decodedManageDataResult.Discriminant = ManageDataResultCode.Decode(stream);
            switch (decodedManageDataResult.Discriminant.InnerValue)
            {
            case ManageDataResultCode.ManageDataResultCodeEnum.MANAGE_DATA_SUCCESS:
                break;

            default:
                break;
            }
            return(decodedManageDataResult);
        }
        public static bool ReadBool(IByteReader r)
        {
            uint val = XdrEncoding.DecodeUInt32(r);

            if (val == 0)
            {
                return(false);
            }
            if (val == 1)
            {
                return(true);
            }

            throw new InvalidOperationException("unexpected value: " + val.ToString());
        }
Esempio n. 43
0
        public static Hello Decode(IByteReader stream)
        {
            Hello decodedHello = new Hello();

            decodedHello.LedgerVersion     = Uint32.Decode(stream);
            decodedHello.OverlayVersion    = Uint32.Decode(stream);
            decodedHello.OverlayMinVersion = Uint32.Decode(stream);
            decodedHello.NetworkID         = Hash.Decode(stream);
            decodedHello.VersionStr        = XdrEncoding.ReadString(stream);
            decodedHello.ListeningPort     = XdrEncoding.DecodeInt32(stream);
            decodedHello.PeerID            = NodeID.Decode(stream);
            decodedHello.Cert  = AuthCert.Decode(stream);
            decodedHello.Nonce = Uint256.Decode(stream);
            return(decodedHello);
        }
Esempio n. 44
0
        public static PaymentResult Decode(IByteReader stream)
        {
            PaymentResult decodedPaymentResult = new PaymentResult();

            decodedPaymentResult.Discriminant = PaymentResultCode.Decode(stream);
            switch (decodedPaymentResult.Discriminant.InnerValue)
            {
            case PaymentResultCode.PaymentResultCodeEnum.PAYMENT_SUCCESS:
                break;

            default:
                break;
            }
            return(decodedPaymentResult);
        }
Esempio n. 45
0
        public static ChangeTrustResult Decode(IByteReader stream)
        {
            ChangeTrustResult decodedChangeTrustResult = new ChangeTrustResult();

            decodedChangeTrustResult.Discriminant = ChangeTrustResultCode.Decode(stream);
            switch (decodedChangeTrustResult.Discriminant.InnerValue)
            {
            case ChangeTrustResultCode.ChangeTrustResultCodeEnum.CHANGE_TRUST_SUCCESS:
                break;

            default:
                break;
            }
            return(decodedChangeTrustResult);
        }
Esempio n. 46
0
        public static AllowTrustResult Decode(IByteReader stream)
        {
            AllowTrustResult decodedAllowTrustResult = new AllowTrustResult();

            decodedAllowTrustResult.Discriminant = AllowTrustResultCode.Decode(stream);
            switch (decodedAllowTrustResult.Discriminant.InnerValue)
            {
            case AllowTrustResultCode.AllowTrustResultCodeEnum.ALLOW_TRUST_SUCCESS:
                break;

            default:
                break;
            }
            return(decodedAllowTrustResult);
        }
Esempio n. 47
0
        public SoaRecord(IByteReader reader)
        {
            if (reader == null)
            {
                return;
            }

            MName   = reader.ReadLabels();
            RName   = reader.ReadLabels();
            Serial  = reader.ReadUInt();
            Refresh = reader.ReadUInt();
            Retry   = reader.ReadUInt();
            Expire  = reader.ReadUInt();
            Minimum = reader.ReadUInt();
        }
Esempio n. 48
0
        public static CreateAccountResult Decode(IByteReader stream)
        {
            CreateAccountResult decodedCreateAccountResult = new CreateAccountResult();

            decodedCreateAccountResult.Discriminant = CreateAccountResultCode.Decode(stream);
            switch (decodedCreateAccountResult.Discriminant.InnerValue)
            {
            case CreateAccountResultCode.CreateAccountResultCodeEnum.CREATE_ACCOUNT_SUCCESS:
                break;

            default:
                break;
            }
            return(decodedCreateAccountResult);
        }
Esempio n. 49
0
        public static SetOptionsResult Decode(IByteReader stream)
        {
            SetOptionsResult decodedSetOptionsResult = new SetOptionsResult();

            decodedSetOptionsResult.Discriminant = SetOptionsResultCode.Decode(stream);
            switch (decodedSetOptionsResult.Discriminant.InnerValue)
            {
            case SetOptionsResultCode.SetOptionsResultCodeEnum.SET_OPTIONS_SUCCESS:
                break;

            default:
                break;
            }
            return(decodedSetOptionsResult);
        }
Esempio n. 50
0
        public static ManageOfferResult Decode(IByteReader stream)
        {
            ManageOfferResult decodedManageOfferResult = new ManageOfferResult();

            decodedManageOfferResult.Discriminant = ManageOfferResultCode.Decode(stream);
            switch (decodedManageOfferResult.Discriminant.InnerValue)
            {
            case ManageOfferResultCode.ManageOfferResultCodeEnum.MANAGE_OFFER_SUCCESS:
                decodedManageOfferResult.Success = ManageOfferSuccessResult.Decode(stream);
                break;

            default:
                break;
            }
            return(decodedManageOfferResult);
        }
Esempio n. 51
0
        public static AccountMergeResult Decode(IByteReader stream)
        {
            AccountMergeResult decodedAccountMergeResult = new AccountMergeResult();

            decodedAccountMergeResult.Discriminant = AccountMergeResultCode.Decode(stream);
            switch (decodedAccountMergeResult.Discriminant.InnerValue)
            {
            case AccountMergeResultCode.AccountMergeResultCodeEnum.ACCOUNT_MERGE_SUCCESS:
                decodedAccountMergeResult.SourceAccountBalance = Int64.Decode(stream);
                break;

            default:
                break;
            }
            return(decodedAccountMergeResult);
        }
Esempio n. 52
0
        public static AssetType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(AssetTypeEnum.ASSET_TYPE_NATIVE));

            case 1: return(Create(AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4));

            case 2: return(Create(AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 53
0
        public static LedgerUpgradeType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 1: return(Create(LedgerUpgradeTypeEnum.LEDGER_UPGRADE_VERSION));

            case 2: return(Create(LedgerUpgradeTypeEnum.LEDGER_UPGRADE_BASE_FEE));

            case 3: return(Create(LedgerUpgradeTypeEnum.LEDGER_UPGRADE_MAX_TX_SET_SIZE));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
        public static StellarValue Decode(IByteReader stream)
        {
            StellarValue decodedStellarValue = new StellarValue();

            decodedStellarValue.TxSetHash = Hash.Decode(stream);
            decodedStellarValue.CloseTime = Uint64.Decode(stream);
            int upgradessize = XdrEncoding.DecodeInt32(stream);

            decodedStellarValue.Upgrades = new UpgradeType[upgradessize];
            for (int i = 0; i < upgradessize; i++)
            {
                decodedStellarValue.Upgrades[i] = UpgradeType.Decode(stream);
            }
            decodedStellarValue.Ext = StellarValueExt.Decode(stream);
            return(decodedStellarValue);
        }
Esempio n. 55
0
        public static ManageOfferEffect Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(ManageOfferEffectEnum.MANAGE_OFFER_CREATED));

            case 1: return(Create(ManageOfferEffectEnum.MANAGE_OFFER_UPDATED));

            case 2: return(Create(ManageOfferEffectEnum.MANAGE_OFFER_DELETED));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
        public static CryptoKeyType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(CryptoKeyTypeEnum.KEY_TYPE_ED25519));

            case 1: return(Create(CryptoKeyTypeEnum.KEY_TYPE_PRE_AUTH_TX));

            case 2: return(Create(CryptoKeyTypeEnum.KEY_TYPE_HASH_X));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 57
0
        public static EnvelopeType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 1: return(Create(EnvelopeTypeEnum.ENVELOPE_TYPE_SCP));

            case 2: return(Create(EnvelopeTypeEnum.ENVELOPE_TYPE_TX));

            case 3: return(Create(EnvelopeTypeEnum.ENVELOPE_TYPE_AUTH));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 58
0
        public SensorArray(IByteReader b_reader, ILogger logger)
        {
            _b_reader = b_reader;
            _logger   = logger;

            //set up devices
            _devices = new List <SensorDevice>();//need to get devices into this list
            //here is where you will declare all of the sensors:
            _devices.Add(new Compass(logger));
            _devices.Add(new SonarArray(logger));

            _packet          = new byte[255];
            _running         = true;
            _get_data_thread = new Thread(ReadLoop);
            _get_data_thread.Start();
        }
Esempio n. 59
0
        public static OperationResultCode Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(OperationResultCodeEnum.opINNER));

            case -1: return(Create(OperationResultCodeEnum.opBAD_AUTH));

            case -2: return(Create(OperationResultCodeEnum.opNO_ACCOUNT));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Esempio n. 60
0
        public static AccountFlags Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 1: return(Create(AccountFlagsEnum.AUTH_REQUIRED_FLAG));

            case 2: return(Create(AccountFlagsEnum.AUTH_REVOCABLE_FLAG));

            case 4: return(Create(AccountFlagsEnum.AUTH_IMMUTABLE_FLAG));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }