-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Do not allow setting application data path overrides after the…
… application is initialized
- Loading branch information
1 parent
cb19c32
commit a079700
Showing
2 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,75 @@ | ||
#nullable enable | ||
|
||
using System; | ||
|
||
namespace Uno; | ||
|
||
partial class WinRTFeatureConfiguration | ||
{ | ||
public static class ApplicationData | ||
{ | ||
#if __SKIA__ | ||
private static string? _temporaryFolderPathOverride; | ||
private static string? _localCacheFolderPathOverride; | ||
private static string? _applicationDataPathOverride; | ||
|
||
/// <summary> | ||
/// Allows overriding the root folder path that the application will use | ||
/// to store its TempState folder. | ||
/// </summary> | ||
/// <remarks>Only applies to Skia targets.</remarks> | ||
public static string? TemporaryFolderPathOverride { get; set; } | ||
public static string? TemporaryFolderPathOverride | ||
{ | ||
get => _temporaryFolderPathOverride; | ||
set | ||
{ | ||
EnsureApplicationDataNotInitialized(); | ||
_temporaryFolderPathOverride = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Allows overriding the root folder path that the application will use | ||
/// to store its LocalCache folder. | ||
/// </summary> | ||
/// <remarks>Only applies to Skia targets.</remarks> | ||
public static string? LocalCacheFolderPathOverride { get; set; } | ||
public static string? LocalCacheFolderPathOverride | ||
{ | ||
get => _localCacheFolderPathOverride; | ||
set | ||
{ | ||
EnsureApplicationDataNotInitialized(); | ||
_localCacheFolderPathOverride = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Allows overriding the root folder that the application will use | ||
/// to store its application data folders (LocalFolder, RoamingFolder, etc.). | ||
/// Only applies to Skia targets. | ||
/// </summary> | ||
/// <remarks>Only applies to Skia targets.</remarks> | ||
public static string? ApplicationDataPathOverride { get; set; } | ||
public static string? ApplicationDataPathOverride | ||
{ | ||
get => _applicationDataPathOverride; | ||
set | ||
{ | ||
EnsureApplicationDataNotInitialized(); | ||
_applicationDataPathOverride = value; | ||
} | ||
} | ||
|
||
internal static bool IsApplicationDataInitialized { get; set; } | ||
|
||
private static void EnsureApplicationDataNotInitialized() | ||
{ | ||
if (IsApplicationDataInitialized) | ||
{ | ||
throw new InvalidOperationException( | ||
"The property was set too late in the application lifecycle." + | ||
"Set it in Program.cs, so it is applied before ApplicationData is initialized."); | ||
} | ||
} | ||
#endif | ||
} | ||
} |