Skip to content

Commit faa4d0f

Browse files
authored
Merge pull request #33 from brahmnes/develop
Fix Fxcop error by implement IDisposable on CorrelatingRemotingMessag…
2 parents 18fd7db + 92e66a5 commit faa4d0f

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/ApplicationInsights.ServiceFabric.Native/Net45/CorrelatingRemotingMessageHandler.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/// Service remoting handler that wraps a service and parses correlation id and context, if they have been passed by the caller as
2121
/// message headers. This allows traces the client and the service to log traces with the same relevant correlation id and context.
2222
/// </summary>
23-
public class CorrelatingRemotingMessageHandler : IServiceRemotingMessageHandler
23+
public class CorrelatingRemotingMessageHandler : IServiceRemotingMessageHandler, IDisposable
2424
{
2525
private Lazy<DataContractSerializer> baggageSerializer;
2626

@@ -184,5 +184,39 @@ private static string GetOperationId(string id)
184184
int rootStart = id[0] == '|' ? 1 : 0;
185185
return id.Substring(rootStart, rootEnd - rootStart);
186186
}
187+
188+
#region IDisposable Support
189+
private bool disposedValue = false; // To detect redundant calls
190+
191+
/// <summary>
192+
/// Overridden by derived class to dispose and clean up resources used by <see cref="CorrelatingRemotingMessageHandler"/>.
193+
/// </summary>
194+
/// <param name="disposing">Whether it should dispose managed resources.</param>
195+
protected virtual void Dispose(bool disposing)
196+
{
197+
if (!disposedValue)
198+
{
199+
if (disposing)
200+
{
201+
IDisposable disposableHandler = this.innerHandler as IDisposable;
202+
if (disposableHandler != null)
203+
{
204+
disposableHandler.Dispose();
205+
}
206+
}
207+
208+
disposedValue = true;
209+
}
210+
}
211+
212+
/// <summary>
213+
/// Dispose and clean up resources used by <see cref="CorrelatingRemotingMessageHandler"/>
214+
/// </summary>
215+
public void Dispose()
216+
{
217+
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
218+
Dispose(true);
219+
}
220+
#endregion // IDisposable Support
187221
}
188222
}

0 commit comments

Comments
 (0)