コード例 #1
0
    public int CalculateLease(int id)
    {
        ILeasable property = _leasableRepository.GetLeasable(id);
        Type      type     = property.GetType();

        if (_calculations.TryGetValue(type, out var calculation))
        {
            return(calculation(property));
        }
        throw new Exception("Unexpected type, please extend the calculator");
    }
コード例 #2
0
 public void ShowLeasingCharges(int id)
 {
     leasable = leasableRepository.GetLeasable(id);
     var leasingCharge = GetLeasingCharges((T)leasable);
 }