Skip to content
Ed Askew edited this page Apr 27, 2020 · 2 revisions

Ex1 Loading a type that is not explicitly bound:


dynamic bigIntType = new DynamicObjects.LateType("System.Numerics.BigInteger, System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

if (tBigIntType.IsAvailable)
{

  var one = bigIntType.@new(1);
  var two = bigIntType.@new(2);

  Assert.IsFalse(one.IsEven);
  Assert.AreEqual(true, two.IsEven);

  var tParsed = bigIntType.Parse("4");

  Assert.AreEqual(true, tParsed.IsEven);
}

Ex2 how i worked around DBNull in a PCL library:

private static readonly dynamic LateConvert = new DynamicObjects.LateType(typeof(Convert));
public static bool IsDBNull(object value)
        {

            try
            {
                return LateConvert.IsDBNull(value);
            }
            catch
            {
                return false;
            }
        }