You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

StatisticsStrategyConfiguration.cs 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using Shadowsocks.Controller.Strategy;
  6. namespace Shadowsocks.Model
  7. {
  8. [Serializable]
  9. public class StatisticsStrategyConfiguration
  10. {
  11. public static readonly string ID = "com.shadowsocks.strategy.statistics";
  12. private bool _statisticsEnabled;
  13. private bool _byIsp;
  14. private bool _byHourOfDay;
  15. private int _choiceKeptMinutes;
  16. private int _dataCollectionMinutes;
  17. private int _repeatTimesNum;
  18. public Dictionary<string, float> Calculations;
  19. public StatisticsStrategyConfiguration()
  20. {
  21. var statisticsStrategy = typeof (StatisticsStrategy);
  22. var statisticsData = statisticsStrategy.GetNestedType("StatisticsData");
  23. var properties = statisticsData.GetFields(BindingFlags.Instance | BindingFlags.Public);
  24. Calculations = properties.ToDictionary(p => p.Name, _ => (float) 0);
  25. }
  26. public bool StatisticsEnabled
  27. {
  28. get { return _statisticsEnabled; }
  29. set { _statisticsEnabled = value; }
  30. }
  31. public bool ByIsp
  32. {
  33. get { return _byIsp; }
  34. set { _byIsp = value; }
  35. }
  36. public bool ByHourOfDay
  37. {
  38. get { return _byHourOfDay; }
  39. set { _byHourOfDay = value; }
  40. }
  41. public int ChoiceKeptMinutes
  42. {
  43. get { return _choiceKeptMinutes; }
  44. set { _choiceKeptMinutes = value; }
  45. }
  46. public int DataCollectionMinutes
  47. {
  48. get { return _dataCollectionMinutes; }
  49. set { _dataCollectionMinutes = value; }
  50. }
  51. public int RepeatTimesNum
  52. {
  53. get { return _repeatTimesNum; }
  54. set { _repeatTimesNum = value; }
  55. }
  56. }
  57. }