Refactor public methods

This commit is contained in:
Susko3 2024-02-07 22:17:13 +01:00
parent 6bdb076027
commit 738c28755c
2 changed files with 42 additions and 3 deletions

View File

@ -174,10 +174,11 @@ namespace osu.Desktop
{ {
tools.CreateShortcutForThisExe(); tools.CreateShortcutForThisExe();
tools.CreateUninstallerRegistryEntry(); tools.CreateUninstallerRegistryEntry();
WindowsAssociationManager.InstallAssociations(null); WindowsAssociationManager.InstallAssociations();
}, onAppUpdate: (_, tools) => }, onAppUpdate: (_, tools) =>
{ {
tools.CreateUninstallerRegistryEntry(); tools.CreateUninstallerRegistryEntry();
WindowsAssociationManager.UpdateAssociations();
}, onAppUninstall: (_, tools) => }, onAppUninstall: (_, tools) =>
{ {
tools.RemoveShortcutForThisExe(); tools.RemoveShortcutForThisExe();

View File

@ -51,12 +51,18 @@ namespace osu.Desktop.Windows
new UriAssociation(@"osump", WindowsAssociationManagerStrings.OsuMultiplayer, Icons.Lazer), new UriAssociation(@"osump", WindowsAssociationManagerStrings.OsuMultiplayer, Icons.Lazer),
}; };
public static void InstallAssociations(LocalisationManager? localisation) /// <summary>
/// Installs file and URI associations.
/// </summary>
/// <remarks>
/// Call <see cref="UpdateDescriptions"/> in a timely fashion to keep descriptions up-to-date and localised.
/// </remarks>
public static void InstallAssociations()
{ {
try try
{ {
updateAssociations(); updateAssociations();
updateDescriptions(localisation); updateDescriptions(null); // write default descriptions in case `UpdateDescriptions()` is not called.
NotifyShellUpdate(); NotifyShellUpdate();
} }
catch (Exception e) catch (Exception e)
@ -65,6 +71,38 @@ namespace osu.Desktop.Windows
} }
} }
/// <summary>
/// Updates associations with latest definitions.
/// </summary>
/// <remarks>
/// Call <see cref="UpdateDescriptions"/> in a timely fashion to keep descriptions up-to-date and localised.
/// </remarks>
public static void UpdateAssociations()
{
try
{
updateAssociations();
NotifyShellUpdate();
}
catch (Exception e)
{
Logger.Log(@$"Failed to update file and URI associations: {e.Message}");
}
}
public static void UpdateDescriptions(LocalisationManager localisationManager)
{
try
{
updateDescriptions(localisationManager);
NotifyShellUpdate();
}
catch (Exception e)
{
Logger.Log(@$"Failed to update file and URI association descriptions: {e.Message}");
}
}
/// <summary> /// <summary>
/// Installs or updates associations. /// Installs or updates associations.
/// </summary> /// </summary>