/// <summary> /// Return currency from number code /// </summary> /// <param name="numCode"> /// number code /// </param> /// <param name="currency"> /// currency /// </param> /// <returns> /// true if ISO 4217 contain this currency /// </returns> public static bool TryParse(int numCode, out ICurrency currency) { currency = Parse(numCode); if(currency != null) return true; currency = new UnknownCurrency(numCode); return false; }
/// <summary> /// Return currency from character code /// </summary> /// <param name="charCode"> /// character code /// </param> /// <param name="currency"> /// currency /// </param> /// <returns> /// true if ISO 4217 contain this currency /// </returns> public static bool TryParse(string charCode, out ICurrency currency) { currency = Parse(charCode); if(currency != null) return true; currency = new UnknownCurrency(charCode); return false; }
public void Equals() { ICurrency c1 = Iso4217.RUB; ICurrency c2 = Iso4217.AED; Assert.AreNotEqual(c1, c2); Assert.IsFalse(c1 == c2); ICurrency c3 = Iso4217.RUB; Assert.AreEqual(c1, c3); Assert.IsTrue(c1 == c3); UnknownCurrency uc = new UnknownCurrency("RUB"); Assert.AreNotEqual(c1, uc); Assert.IsFalse(c1 == uc); }