本文整理汇总了C#中RequestContext.Respond方法的典型用法代码示例。如果您正苦于以下问题:C# RequestContext.Respond方法的具体用法?C# RequestContext.Respond怎么用?C# RequestContext.Respond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestContext
的用法示例。
在下文中一共展示了RequestContext.Respond方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSubmitAddress
/// <summary> Executes the submit address action. </summary>
///
/// <remarks> Paul, 25/01/2015. </remarks>
///
/// <exception cref="ApiExceptionMessage"> Thrown when an API exception message error
/// condition occurs. </exception>
/// <exception cref="ApiExceptionMissingParameter"> Thrown when an API exception missing
/// parameter error condition occurs. </exception>
///
/// <param name="ctx"> The context. </param>
/// <param name="dummy"> The dummy. </param>
///
/// <returns> A Task. </returns>
Task OnSubmitAddress(RequestContext ctx, IDummy dummy)
{
CurrencyTypes fromCurrency = RestHelpers.GetPostArg<CurrencyTypes, ApiExceptionMissingParameter>(ctx, WebForms.kFromCurrency);
CurrencyTypes toCurrency = RestHelpers.GetPostArg<CurrencyTypes, ApiExceptionMissingParameter>(ctx, WebForms.kToCurrency);
string receivingAddress = RestHelpers.GetPostArg<string, ApiExceptionMissingParameter>(ctx, WebForms.kReceivingAddress);
SubmitAddressResponse response;
if (fromCurrency == CurrencyTypes.BTC && toCurrency == CurrencyTypes.bitBTC)
{
string accountName = receivingAddress;
// try and retrieve a previous entry
SenderToDepositRow senderToDeposit = m_database.Query<SenderToDepositRow>("SELECT * FROM sender_to_deposit WHERE [email protected];", accountName).FirstOrDefault();
if (senderToDeposit == null || !BitsharesWallet.IsValidAccountName(accountName))
{
// no dice, create a new entry
// validate bitshares account name
try
{
BitsharesAccount account = m_bitshares.WalletGetAccount(accountName);
// generate a new bitcoin address and tie it to this account
string depositAdress = m_bitcoin.GetNewAddress();
senderToDeposit = InsertSenderToDeposit(account.name, depositAdress);
}
catch (BitsharesRpcException)
{
throw new ApiExceptionMessage(accountName + " is not an existing account! Are you sure it is registered?");
}
}
response = new SubmitAddressResponse { deposit_address = senderToDeposit.deposit_address };
}
else if (fromCurrency == CurrencyTypes.bitBTC && toCurrency == CurrencyTypes.BTC)
{
string bitcoinAddress = receivingAddress;
// try and retrieve a previous entry
SenderToDepositRow senderToDeposit = m_database.Query<SenderToDepositRow>("SELECT * FROM sender_to_deposit WHERE [email protected];", bitcoinAddress).FirstOrDefault();
if (senderToDeposit == null)
{
// validate bitcoin address
byte[] check = Util.Base58CheckToByteArray(bitcoinAddress);
if (check == null)
{
throw new ApiExceptionMessage(bitcoinAddress + " is not a valid bitcoin address!");
}
// generate a memo field to use instead
string start = "meta-";
string memo = start + bitcoinAddress.Substring(0, BitsharesWallet.kBitsharesMaxMemoLength - start.Length);
senderToDeposit = InsertSenderToDeposit(bitcoinAddress, memo);
}
response = new SubmitAddressResponse { deposit_address = m_bitsharesAccount, memo = senderToDeposit.deposit_address };
}
else
{
throw new ApiExceptionUnsupportedTrade(fromCurrency, toCurrency);
}
ctx.Respond<SubmitAddressResponse>(response);
return null;
}
示例2: OnGetStats
/// <summary> Executes the get statistics action. </summary>
///
/// <remarks> Paul, 30/01/2015. </remarks>
///
/// <param name="ctx"> The context. </param>
/// <param name="dummy"> The dummy. </param>
///
/// <returns> A Task. </returns>
Task OnGetStats(RequestContext ctx, IDummy dummy)
{
uint sinceTid = RestHelpers.GetPostArg<uint, ApiExceptionMissingParameter>(ctx, WebForms.kLimit);
List<TransactionsRow> lastTransactions = m_database.Query<TransactionsRow>("SELECT * FROM transactions WHERE uid>@uid ORDER BY uid;", sinceTid);
SiteStatsRow stats = new SiteStatsRow
{
bid_price = m_bidPrice,
ask_price = m_askPrice,
max_bitassets = m_bitsharesDepositLimit,
max_btc = m_bitcoinDepositLimit
};
ctx.Respond<StatsPacket>(new StatsPacket { m_lastTransactions = lastTransactions, m_stats = stats });
return null;
}