init
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTS.Common.Import.Persist
|
||||
{
|
||||
public class PersistCalculator : IPersistCalculator
|
||||
{
|
||||
|
||||
private double _done;
|
||||
private double _total;
|
||||
|
||||
public double ProgressValue { get => _done / _total; }
|
||||
|
||||
public void AddDone(double value)
|
||||
{
|
||||
_done += value;
|
||||
}
|
||||
|
||||
public void AddDone()
|
||||
{
|
||||
_done++;
|
||||
}
|
||||
|
||||
public void AddToTotal(double value)
|
||||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", "value should not be less or equal to zero.");
|
||||
}
|
||||
_total += value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public interface IPersistCalculator
|
||||
{
|
||||
void AddDone();
|
||||
void AddDone(double value);
|
||||
double ProgressValue { get; }
|
||||
void AddToTotal(double value);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user