Nullify Scoped Service Delegates

This commit is contained in:
MidoriKami 2023-09-19 23:43:45 -07:00
parent b0986a5225
commit c305c01dfd
9 changed files with 27 additions and 1 deletions

View file

@ -189,6 +189,8 @@ internal class ConditionPluginScoped : IDisposable, IServiceType, ICondition
public void Dispose()
{
this.conditionService.ConditionChange -= this.ConditionChangedForward;
this.ConditionChange = null;
}
/// <inheritdoc/>

View file

@ -210,6 +210,11 @@ internal class DutyStatePluginScoped : IDisposable, IServiceType, IDutyState
this.dutyStateService.DutyWiped -= this.DutyWipedForward;
this.dutyStateService.DutyRecommenced -= this.DutyRecommencedForward;
this.dutyStateService.DutyCompleted -= this.DutyCompletedForward;
this.DutyStarted = null;
this.DutyWiped = null;
this.DutyRecommenced = null;
this.DutyCompleted = null;
}
private void DutyStartedForward(object sender, ushort territoryId) => this.DutyStarted?.Invoke(sender, territoryId);

View file

@ -460,6 +460,11 @@ internal class ChatGuiPluginScoped : IDisposable, IServiceType, IChatGui
this.chatGuiService.CheckMessageHandled -= this.OnCheckMessageForward;
this.chatGuiService.ChatMessageHandled -= this.OnMessageHandledForward;
this.chatGuiService.ChatMessageUnhandled -= this.OnMessageUnhandledForward;
this.ChatMessage = null;
this.CheckMessageHandled = null;
this.ChatMessageHandled = null;
this.ChatMessageUnhandled = null;
}
/// <inheritdoc/>

View file

@ -307,6 +307,8 @@ internal class FlyTextGuiPluginScoped : IDisposable, IServiceType, IFlyTextGui
public void Dispose()
{
this.flyTextGuiService.FlyTextCreated -= this.FlyTextCreatedForward;
this.FlyTextCreated = null;
}
/// <inheritdoc/>

View file

@ -566,6 +566,10 @@ internal class GameGuiPluginScoped : IDisposable, IServiceType, IGameGui
this.gameGuiService.UiHideToggled -= this.UiHideToggledForward;
this.gameGuiService.HoveredItemChanged -= this.HoveredItemForward;
this.gameGuiService.HoveredActionChanged -= this.HoveredActionForward;
this.UiHideToggled = null;
this.HoveredItemChanged = null;
this.HoveredActionChanged = null;
}
/// <inheritdoc/>

View file

@ -156,6 +156,8 @@ internal class PartyFinderGuiPluginScoped : IDisposable, IServiceType, IPartyFin
public void Dispose()
{
this.partyFinderGuiService.ReceiveListing -= this.ReceiveListingForward;
this.ReceiveListing = null;
}
private void ReceiveListingForward(PartyFinderListing listing, PartyFinderListingEventArgs args) => this.ReceiveListing?.Invoke(listing, args);

View file

@ -417,6 +417,10 @@ internal class ToastGuiPluginScoped : IDisposable, IServiceType, IToastGui
this.toastGuiService.Toast -= this.ToastForward;
this.toastGuiService.QuestToast -= this.QuestToastForward;
this.toastGuiService.ErrorToast -= this.ErrorToastForward;
this.Toast = null;
this.QuestToast = null;
this.ErrorToast = null;
}
/// <inheritdoc/>

View file

@ -169,6 +169,8 @@ internal class GameNetworkPluginScoped : IDisposable, IServiceType, IGameNetwork
public void Dispose()
{
this.gameNetworkService.NetworkMessage -= this.NetworkMessageForward;
this.NetworkMessage = null;
}
private void NetworkMessageForward(nint dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction)

View file

@ -651,7 +651,7 @@ public static class Util
/// </summary>
/// <param name="path">The path of the file to write to.</param>
/// <param name="text">The text to write.</param>
internal static void WriteAllTextSafe(string path, string text)
public static void WriteAllTextSafe(string path, string text)
{
var tmpPath = path + ".tmp";
if (File.Exists(tmpPath))