Merge pull request #35 from alex6dj/Fix_IDisposable_implementation

Use Dispose pattern in FormBase IDisposable implementation
This commit is contained in:
Florian Zevedei 2023-01-21 16:56:21 +01:00 committed by GitHub
commit 25019f6c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Args;
using TelegramBotBase.Base;
@ -17,7 +16,6 @@ namespace TelegramBotBase.Form
/// </summary>
public class FormBase : IDisposable
{
public NavigationController NavigationController { get; set; }
public DeviceSession Device { get; set; }
@ -432,14 +430,29 @@ namespace TelegramBotBase.Form
}
}
protected virtual void Dispose(bool disposing)
{
if (this.IsDisposed)
{
return;
}
if (disposing)
{
this.Client = null;
this.Device = null;
}
this.IsDisposed = true;
}
/// <summary>
/// Cleanup
/// </summary>
public void Dispose()
{
this.Client = null;
this.Device = null;
this.IsDisposed = true;
Dispose(true);
GC.SuppressFinalize(this);
}
}
}