変数userManager
と変数signInManager
はどちらも、インスタンス化できるクラス レベルのインスタンス メンバーであるか、null になる可能性があります。
これを置き換えても安全ですか:
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (this.userManager != null)
{
this.userManager.Dispose();
this.userManager = null;
}
if (this.signInManager != null)
{
this.signInManager.Dispose();
this.signInManager = null;
}
}
base.Dispose(disposing);
}
これとともに:
protected override void Dispose(bool disposing)
{
if (disposing)
{
this.userManager?.Dispose();
this.signInManager?.Dispose();
}
base.Dispose(disposing);
}
個人的には、変数を破棄した後に変数を明示的に null に割り当てる意味がわかりません。変数は静的ではないため、私が知る限り、何もしません。