/// <summary> /// Creates an instance of the <see cref="AccountStatus"/> class from an unparsed record. /// </summary> /// <param name="key">The key of the record.</param> /// <param name="record">The record to create the object from.</param> /// <returns>A new instance of the <see cref="AccountStatus"/> class.</returns> public static AccountStatus FromRecord(RecordKey key, Record record) { if (key.RecordType != RecordType.Account) { throw new ArgumentOutOfRangeException(nameof(key)); } long amount; if (record.Value.Value.Count == 0) { amount = 0; } else if (record.Value.Value.Count == 8) { amount = BitConverter.ToInt64(record.Value.Value.Reverse().ToArray(), 0); } else { throw new ArgumentOutOfRangeException(nameof(record)); } return(new AccountStatus(new AccountKey(key.Path, LedgerPath.Parse(key.Name)), amount, record.Version)); }
/// <summary> /// Creates a new instance of the <see cref="AccountKey"/> class from an account and asset. /// </summary> /// <param name="account">The account path.</param> /// <param name="asset">The asset path.</param> /// <returns>An instance of the <see cref="AccountKey"/> class representing the account and asset provided.</returns> public static AccountKey Parse(string account, string asset) { return(new AccountKey( LedgerPath.Parse(account), LedgerPath.Parse(asset))); }