add an option for Ping tests (disabled by default) and improve the readability of the code

This commit is contained in:
icylogic
2016-01-20 23:51:51 +08:00
parent 586caab7c4
commit bec1f808b3
5 changed files with 140 additions and 224 deletions
@@ -13,13 +13,13 @@ namespace Shadowsocks.Model
[Serializable]
public class StatisticsStrategyConfiguration
{
public static readonly string ID = "com.shadowsocks.strategy.statistics";
private bool _statisticsEnabled = true;
private bool _byIsp = false;
private bool _byHourOfDay = false;
private int _choiceKeptMinutes = 10;
private int _dataCollectionMinutes = 10;
private int _repeatTimesNum = 4;
public static readonly string ID = "com.shadowsocks.strategy.statistics";
public bool StatisticsEnabled { get; } = true;
public bool ByHourOfDay { get; } = true;
public bool Ping { get; set; }
public int ChoiceKeptMinutes { get; } = 10;
public int DataCollectionMinutes { get; } = 10;
public int RepeatTimesNum { get; } = 4;
private const string ConfigFile = "statistics-config.json";
@@ -64,41 +64,5 @@ namespace Shadowsocks.Model
var properties = typeof(StatisticsRecord).GetFields(BindingFlags.Instance | BindingFlags.Public);
Calculations = properties.ToDictionary(p => p.Name, _ => (float)0);
}
public bool StatisticsEnabled
{
get { return _statisticsEnabled; }
set { _statisticsEnabled = value; }
}
public bool ByIsp
{
get { return _byIsp; }
set { _byIsp = value; }
}
public bool ByHourOfDay
{
get { return _byHourOfDay; }
set { _byHourOfDay = value; }
}
public int ChoiceKeptMinutes
{
get { return _choiceKeptMinutes; }
set { _choiceKeptMinutes = value; }
}
public int DataCollectionMinutes
{
get { return _dataCollectionMinutes; }
set { _dataCollectionMinutes = value; }
}
public int RepeatTimesNum
{
get { return _repeatTimesNum; }
set { _repeatTimesNum = value; }
}
}
}