public void TestNullableGet() { NamedValueSet properties = new NamedValueSet(); decimal? notional = null; // using GetValue<T> notional = properties.GetValue <decimal>("Notional", false); Assert.IsTrue(notional.HasValue); Assert.AreEqual <decimal>(0.0M, notional.Value); // using GetNullable<T> // - value is missing notional = properties.GetNullable <decimal>("Notional"); Assert.IsFalse(notional.HasValue); Assert.AreEqual <decimal?>(null, notional); // - value not missing properties.Set("Notional", 1.0M); notional = properties.GetNullable <decimal>("Notional"); Assert.IsTrue(notional.HasValue); Assert.AreEqual <decimal?>(1.0M, notional); }
/// <summary> /// A helper to extract properties from a named value set.. /// </summary> /// <param name="properties">The collection of properties.</param> public static DateTime?ExtractMarketDate(NamedValueSet properties) { return(properties.GetNullable <DateTime>(CurveProp.MarketDate)); }