File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ namespace LibGit2Sharp
12
12
/// A remote repository whose branches are tracked.
13
13
/// </summary>
14
14
[ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
15
- public class Remote : IEquatable < Remote > , IBelongToARepository
15
+ public class Remote : IEquatable < Remote > , IBelongToARepository , IDisposable
16
16
{
17
17
private static readonly LambdaEqualityHelper < Remote > equalityHelper =
18
18
new LambdaEqualityHelper < Remote > ( x => x . Name , x => x . Url , x => x . PushUrl ) ;
@@ -43,12 +43,37 @@ internal Remote(RemoteSafeHandle handle, Repository repository)
43
43
44
44
~ Remote ( )
45
45
{
46
- if ( handle != null )
46
+ Dispose ( false ) ;
47
+ }
48
+
49
+ #region IDisposable
50
+
51
+ bool disposedValue = false ; // To detect redundant calls
52
+
53
+ /// <summary>
54
+ /// Release the unmanaged remote object
55
+ /// </summary>
56
+ public void Dispose ( )
57
+ {
58
+ Dispose ( true ) ;
59
+ GC . SuppressFinalize ( this ) ;
60
+ }
61
+
62
+ void Dispose ( bool disposing )
63
+ {
64
+ if ( ! disposedValue )
47
65
{
48
- handle . Dispose ( ) ;
66
+ if ( handle != null )
67
+ {
68
+ handle . Dispose ( ) ;
69
+ }
70
+
71
+ disposedValue = true ;
49
72
}
50
73
}
51
74
75
+ #endregion
76
+
52
77
/// <summary>
53
78
/// Gets the alias of this remote repository.
54
79
/// </summary>
You can’t perform that action at this time.
0 commit comments