예제 #1
0
 /// <summary>
 /// Returns the unit derived from this unit using the specified converter. The
 /// converter does not need to be linear.
 /// </summary>
 /// <param name="operation"> The converter from the transformed unit to this unit. </param>
 public Unit Transform(UnitConverter operation)
 {
     if (this is TransformedUnit)
     {
         TransformedUnit tu        = (TransformedUnit)this;
         Unit            parent    = tu.parent;
         UnitConverter   converter = tu.toParent.Concatenate(operation);
         if (converter == UnitConverter.IDENTITY)
         {
             return(parent);
         }
         else
         {
             return(new TransformedUnit(parent.__quantity, parent, converter));
         }
     }
     else if (operation == UnitConverter.IDENTITY)
     {
         return(this);
     }
     else
     {
         return(new TransformedUnit(__quantity, this, operation));
     }
 }
예제 #2
0
 public override bool Equals(object other)
 {
     if (this == other)
     {
         return(true);
     }
     else if (other is TransformedUnit)
     {
         TransformedUnit tu = (TransformedUnit)other;
         return(parent.Equals(tu.parent) && toParent.Equals(tu.toParent));
     }
     else
     {
         return(false);
     }
 }