Browse Source

follow CA1001: Types that own disposable fields should be disposable

https://msdn.microsoft.com/library/ms182172.aspx
tags/3.0
icylogic 8 years ago
parent
commit
586caab7c4
2 changed files with 15 additions and 2 deletions
  1. +8
    -1
      shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs
  2. +7
    -1
      shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs

+ 8
- 1
shadowsocks-csharp/Controller/Service/AvailabilityStatistics.cs View File

@@ -16,7 +16,7 @@ namespace Shadowsocks.Controller
{ {
using Statistics = Dictionary<string, List<StatisticsRecord>>; using Statistics = Dictionary<string, List<StatisticsRecord>>;


public sealed class AvailabilityStatistics
public sealed class AvailabilityStatistics : IDisposable
{ {
public const string DateTimePattern = "yyyy-MM-dd HH:mm:ss"; public const string DateTimePattern = "yyyy-MM-dd HH:mm:ss";
private const string StatisticsFilesName = "shadowsocks.availability.json"; private const string StatisticsFilesName = "shadowsocks.availability.json";
@@ -342,5 +342,12 @@ namespace Shadowsocks.Controller
Server = server; Server = server;
} }
} }

public void Dispose()
{
_recorder.Dispose();
_writer.Dispose();
_speedMonior.Dispose();
}
} }
} }

+ 7
- 1
shadowsocks-csharp/Controller/Strategy/StatisticsStrategy.cs View File

@@ -12,7 +12,8 @@ using Shadowsocks.Model;
namespace Shadowsocks.Controller.Strategy namespace Shadowsocks.Controller.Strategy
{ {
using Statistics = Dictionary<string, List<StatisticsRecord>>; using Statistics = Dictionary<string, List<StatisticsRecord>>;
class StatisticsStrategy : IStrategy

internal class StatisticsStrategy : IStrategy, IDisposable
{ {
private readonly ShadowsocksController _controller; private readonly ShadowsocksController _controller;
private Server _currentServer; private Server _currentServer;
@@ -152,5 +153,10 @@ namespace Shadowsocks.Controller.Strategy
{ {
//TODO: combine this part of data with ICMP statics //TODO: combine this part of data with ICMP statics
} }

public void Dispose()
{
_timer.Dispose();
}
} }
} }

Loading…
Cancel
Save