Ejemplo n.º 1
0
 /// <summary>
 /// Returns whether the two specified coproducts are structurally equal. Note that two nulls are
 /// considered structurally equal coproducts.
 /// </summary>
 public static bool CoproductEquals(this ICoproduct c1, object that)
 {
     if (that is ICoproduct c2 && c1 != null && c2 != null && c1.GetType() == c2.GetType())
     {
         return(c1.CoproductRepresentation().Equals(c2.CoproductRepresentation()));
     }
     return(c1 == that);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns string representation of the specified coproduct type.
 /// </summary>
 public static string CoproductToString(this ICoproduct c)
 {
     return
         (c.GetType().SimpleName() + "(" +
          GetOrdinal(c.CoproductDiscriminator) + "(" +
          c.CoproductValue.SafeToString() +
          ")" +
          ")");
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Returns hash code of the specified coproduct.
 /// </summary>
 public static int CoproductHashCode(this ICoproduct c)
 {
     return(Structural.HashCode(new[] { c.CoproductArity, c.CoproductDiscriminator, c.CoproductValue }));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Canonical representation of the coproduct.
 /// </summary>
 public static IProduct3 <int, int, object> CoproductRepresentation(this ICoproduct c)
 {
     return(Product3.Create(c.CoproductArity, c.CoproductDiscriminator, c.CoproductValue));
 }