本文整理汇总了C#中Currency类的典型用法代码示例。如果您正苦于以下问题:C# Currency类的具体用法?C# Currency怎么用?C# Currency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Currency类属于命名空间,在下文中一共展示了Currency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReEntry
public void ReEntry(Currency currencyForPosition, Currency baseCurrency, DateTime dateTime)
{
Status = PositionRuntimeStatus.Active;
// create a new trade record
_currentPositionRecord = new PositionRecord(dateTime, currencyForPosition, baseCurrency, PositionType, this);
PositionRecords.Add(_currentPositionRecord);
}
示例2: PositiveAmountSchedule
public PositiveAmountSchedule(XmlNode xmlNode)
: base(xmlNode)
{
XmlNode currencyNode = xmlNode.SelectSingleNode("currency");
if (currencyNode != null)
{
if (currencyNode.Attributes["href"] != null || currencyNode.Attributes["id"] != null)
{
if (currencyNode.Attributes["id"] != null)
{
currencyIDRef_ = currencyNode.Attributes["id"].Value;
Currency ob = new Currency(currencyNode);
IDManager.SetID(currencyIDRef_, ob);
}
else if (currencyNode.Attributes["href"] != null)
{
currencyIDRef_ = currencyNode.Attributes["href"].Value;
}
else
{
currency_ = new Currency(currencyNode);
}
}
else
{
currency_ = new Currency(currencyNode);
}
}
}
示例3: ExchangeRate
/// <summary>
/// the rate r is given with the convention that a
/// unit of the source is worth r units of the target.
/// </summary>
/// <param name="source"></param>
/// <param name="target"></param>
/// <param name="rate"></param>
public ExchangeRate(Currency source, Currency target, double rate)
{
source_ = source;
target_ = target;
rate_ = rate;
type_ = Type.Direct;
}
示例4: AmountSchedule
public AmountSchedule(XmlNode xmlNode)
: base(xmlNode)
{
XmlNodeList currencyNodeList = xmlNode.SelectNodes("currency");
if (currencyNodeList.Count > 1 )
{
throw new Exception();
}
foreach (XmlNode item in currencyNodeList)
{
if (item.Attributes["href"] != null || item.Attributes["id"] == null)
{
if (item.Attributes["id"] != null)
{
currencyIDRef = item.Attributes["id"].Name;
Currency ob = Currency();
IDManager.SetID(currencyIDRef, ob);
}
else if (item.Attributes.ToString() == "href")
{
currencyIDRef = item.Attributes["href"].Name;
}
else
{
currency = new Currency(item);
}
}
}
}
示例5: button3_Click
private void button3_Click(object sender, RoutedEventArgs e)
{
NavigationService ns;
ns = NavigationService.GetNavigationService(this);
Currency nextPage = new Currency();
ns.Navigate(nextPage);
}
示例6: Can_formatPrice_with_distinct_currencyDisplayLocale
public void Can_formatPrice_with_distinct_currencyDisplayLocale()
{
var usd_currency = new Currency()
{
Id = 1,
Name = "US Dollar",
CurrencyCode = "USD",
DisplayLocale = "en-US",
};
var rub_currency = new Currency()
{
Id = 2,
Name = "Russian Ruble",
CurrencyCode = "RUB",
DisplayLocale = "ru-RU",
};
var language = new Language()
{
Id = 1,
Name = "English",
LanguageCulture = "en-US"
};
_priceFormatter.FormatPrice(1234.5M, false, usd_currency, language, false, false).ShouldEqual("$1,234.50");
_priceFormatter.FormatPrice(1234.5M, false, rub_currency, language, false, false).ShouldEqual("1 234,50р.");
}
示例7: GetExchangeRates
public static double[] GetExchangeRates(Currency transactionCurrency, Currency pivotCurrency, Currency globalPivotCurrency)
{
double[] rates = new double[2];
if (transactionCurrency.Id == pivotCurrency.Id)
rates[0] = 1.00;
else
{
if (transactionCurrency.Rate != 0)
rates[0] = pivotCurrency.Rate * transactionCurrency.Rate;
else
rates[0] = 0;
}
if (transactionCurrency.Id == globalPivotCurrency.Id)
rates[1] = 1.00;
else
{
if (transactionCurrency.Rate != 0)
rates[1] = globalPivotCurrency.Rate * transactionCurrency.Rate;
else
rates[1] = 0;
}
return rates;
}
示例8: CreateRecord
public bool CreateRecord(Object Currency)
{
Boolean flag = false;
CurrencyMaster currency = (CurrencyMaster)Currency;
try
{
Currency _currency = new Currency();
if (currency.CurrencyName != null)
{
_currency.Name = currency.CurrencyName.ToUpper().Trim();
}
if (currency.Symbol != null)
{
_currency.Symbol = currency.Symbol;
}
_currency.CreateBy = currency.CreateBy;
_currency.CreateDate = DateTime.Now;
if (_currency.Name != null)
{
flag = DAL.DALCurrency.CreateCurrency(_currency);
}
}
catch (Exception ex)
{
throw;
}
return flag;
}
示例9: Main
static void Main()
{
try
{
Currency balance = new Currency(50,35);
Console.WriteLine(balance);
Console.WriteLine("balance is " + balance);
Console.WriteLine("balance is (using ToString()) " + balance.ToString());
float balance2= balance;
Console.WriteLine("After converting to float, = " + balance2);
balance = (Currency) balance2;
Console.WriteLine("After converting back to Currency, = " + balance);
Console.WriteLine(
"Now attempt to convert out of range value of -$100.00 to a Currency:");
checked
{
balance = (Currency) (-50.5);
Console.WriteLine("Result is " + balance.ToString());
}
}
catch(Exception e)
{
Console.WriteLine("Exception occurred: " + e.Message);
}
}
示例10: ConvertTo
public static decimal ConvertTo(decimal fromAmount, CurrencyType fromCurrencyType, CurrencyType toCurrencyType, Currency[] currencies)
{
if (fromCurrencyType == toCurrencyType)
return fromAmount;
if ((fromCurrencyType != CurrencyType.CZK && currencies.All(c => c.CurrencyType != fromCurrencyType)) ||
toCurrencyType != CurrencyType.CZK && currencies.All(c => c.CurrencyType != toCurrencyType))
{
throw new Exception(String.Format(ValidationResource.Currency_CannotProccessCurrencyChange_ErrorMessage, fromCurrencyType, toCurrencyType));
}
decimal amountTo = fromAmount;
Currency currency;
// Převod konta na CZK
if (fromCurrencyType != CurrencyType.CZK)
{
currency = currencies.Single(c => c.CurrencyType == fromCurrencyType);
amountTo = amountTo * currency.ExchangeRateToCZK;
}
// Převod konta na aktuální měnu
if (toCurrencyType != CurrencyType.CZK)
{
currency = currencies.Single(c => c.CurrencyType == toCurrencyType);
amountTo = amountTo / currency.ExchangeRateToCZK;
}
return amountTo;
}
示例11: BtnSubmit_Click
protected void BtnSubmit_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
string redirectPage = null;
try
{
Currency info = new Currency();
info.UnitAr = txtUnitAr.Text.Trim();
info.UnitEn = txtUnitEn.Text.Trim();
if (Request.QueryString[CommonStrings.ID] != null)
{
info.ID = Convert.ToInt32(Request.QueryString[CommonStrings.ID]);
if (currencysOperator.Update(info))
redirectPage = Utility.AppendQueryString(PagesPathes.ConfirmUpdate, new KeyValue(CommonStrings.BackUrl, "CurrencyList"));
}
else
{
if (currencysOperator.Add(info))
redirectPage = Utility.AppendQueryString(PagesPathes.ConfirmInsert, new KeyValue(CommonStrings.BackUrl, "CurrencyList"));
}
}
catch
{
redirectPage = Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, "CurrencyList"));
}
finally
{
Response.Redirect(redirectPage);
}
}
}
示例12: GetOrCreateNewTransientCartAsync
public async Task<CartBuilder> GetOrCreateNewTransientCartAsync(Store store, Customer customer, Language language, Currency currency)
{
_store = store;
_customer = customer;
_currency = currency;
_language = language;
_cartCacheKey = GetCartCacheKey(store.Id, customer.Id);
_cart = await _cacheManager.GetAsync(_cartCacheKey, _cartCacheRegion, async () =>
{
ShoppingCart retVal;
var cartSearchResult = await _cartApi.CartModuleGetCurrentCartAsync(_store.Id, _customer.Id);
if (cartSearchResult == null)
{
retVal = CreateNewTransientCart();
}
else
{
var detalizedCart = await _cartApi.CartModuleGetCartByIdAsync(cartSearchResult.Id);
retVal = detalizedCart.ToWebModel(_currency, _language);
}
return retVal;
});
await EvaluatePromotionsAsync();
return this;
}
示例13: OpenPosition
public void OpenPosition(Currency currencyForPosition, Currency baseCurrency, DateTime dateTime)
{
Status = PositionRuntimeStatus.Active;
_currentPositionRecord = new PositionRecord(dateTime, currencyForPosition, baseCurrency, PositionType, this);
PositionRecords.Add(_currentPositionRecord);
}
示例14: GetCurrencyString
/// <summary>
/// Gets currency string
/// </summary>
/// <param name="amount">Amount</param>
/// <param name="showCurrency">A value indicating whether to show a currency</param>
/// <param name="targetCurrency">Target currency</param>
/// <returns>Currency string without exchange rate</returns>
protected virtual string GetCurrencyString(decimal amount,
bool showCurrency, Currency targetCurrency)
{
if (targetCurrency == null)
throw new ArgumentNullException("targetCurrency");
string result;
if (!String.IsNullOrEmpty(targetCurrency.CustomFormatting))
{
//custom formatting specified by a store owner
result = amount.ToString(targetCurrency.CustomFormatting);
}
else
{
if (!String.IsNullOrEmpty(targetCurrency.DisplayLocale))
{
//default behavior
result = amount.ToString("C", new CultureInfo(targetCurrency.DisplayLocale));
}
else
{
//not possible because "DisplayLocale" should be always specified
//but anyway let's just handle this behavior
result = String.Format("{0} ({1})", amount.ToString("N"), targetCurrency.CurrencyCode);
return result;
}
}
//display currency code?
if (showCurrency && _currencySettings.DisplayCurrencyLabel)
result = String.Format("{0} ({1})", result, targetCurrency.CurrencyCode);
return result;
}
示例15: Money
public Money(string currencyCode, decimal amount) {
_currency = new Currency();
if (currencyCode != null) {//sometimes a null currencyCode is passed. This might be a bug somewhere
_currency.CurrencyCode = currencyCode;
}
Amount = amount;
}