-
Notifications
You must be signed in to change notification settings - Fork 666
DYN-9958 WebView2 cache folder location #16787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
cd35fca
567a17c
8f0ab3f
2f06b8d
2a6b092
7c8ec1e
4a2db49
15a042b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Text; | ||
| using System.Threading; | ||
| using Dynamo.Configuration; | ||
| using Dynamo.Utilities; | ||
|
|
||
| namespace Dynamo.Wpf.UI | ||
| { | ||
| /// <summary> | ||
| /// Provides static methods and properties for initializing and managing the host startup context during application | ||
| /// launch. | ||
| /// </summary> | ||
| /// <remarks><see cref="HostStartup"/> is intended for use during the application's splash screen or early | ||
| /// startup phase, before other core services are available. It allows initialization of a shared startup context | ||
| /// and provides access to user-specific directories based on the current host environment.</remarks> | ||
| public static class HostStartup | ||
| { | ||
| private static int _initialized; | ||
| public static SplashScreenStartupContext? Current { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Initialize the HostStartup with the provided context. | ||
| /// </summary> | ||
| /// <param name="context"></param> | ||
| /// <returns></returns> | ||
| public static bool TryInitialize(SplashScreenStartupContext context) | ||
| { | ||
| if (context == null) return false; | ||
| if (Interlocked.CompareExchange(ref _initialized, 1, 0) != 0) return false; | ||
| Current = context; | ||
| return true; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Resets the static state of the class to its initial, uninitialized condition. | ||
| /// </summary> | ||
| /// <remarks>Call this method to clear any existing state and reinitialize the class as if it had | ||
| /// not been used. This is typically used for testing scenarios or to force reinitialization. This method is | ||
| /// not thread-safe; ensure that no other threads are accessing the class while calling <see | ||
| /// cref="Reset"/>.</remarks> | ||
| public static void Reset() | ||
| { | ||
| Current = null; | ||
| Interlocked.Exchange(ref _initialized, 0); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the path to the user-specific directory for the current application version. | ||
| /// </summary> | ||
| /// <remarks>The returned directory path is versioned based on the application's major and minor | ||
| /// version numbers. If user-specific host information is available, the path is constructed using the host's | ||
| /// user data folder; otherwise, it defaults to a standard location under the user's application data | ||
| /// folder.</remarks> | ||
| /// <returns>A string containing the full path to the user directory for the current application version. The directory | ||
| /// may not exist and may need to be created by the caller.</returns> | ||
| public static string GetUserDirectory() | ||
| { | ||
| //we need to use userDataFolder and hostAnalyticsInfo just in SplashScreen due that PathManager/PathResolver are not created yet when SplashScreen is launched from a host | ||
RobertGlobant20 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (Current != null && !string.IsNullOrEmpty(Current.UserDataFolder) && Current.HostInfo != null) | ||
| { | ||
| var version = Current.HostInfo.Value.HostVersion; | ||
|
|
||
| return Path.Combine(Current.UserDataFolder, | ||
| String.Format("{0}.{1}", version.Major, version.Minor)); | ||
|
||
| } | ||
| else | ||
| { | ||
| var version = AssemblyHelper.GetDynamoVersion(); | ||
|
|
||
| var folder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
| return Path.Combine(Path.Combine(folder, Configurations.DynamoAsString, "Dynamo Core"), | ||
| String.Format("{0}.{1}", version.Major, version.Minor)); | ||
|
||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||
| using Dynamo.Models; | ||||||
|
|
||||||
| namespace Dynamo.Wpf.UI | ||||||
| { | ||||||
| /// <summary> | ||||||
| /// Provides contextual information for initializing a splash screen during application startup, including host | ||||||
| /// analytics data and the user data folder path. | ||||||
| /// </summary> | ||||||
| /// <remarks>This context is typically used to supply startup-related information to components that | ||||||
| /// display or manage a splash screen. It encapsulates optional host analytics details and the location of the | ||||||
| /// user-specific data directory.</remarks> | ||||||
| public sealed class SplashScreenStartupContext | ||||||
| { | ||||||
| /// <summary> | ||||||
| /// Initializes a new instance of the <see cref="SplashScreenStartupContext"/> class with the specified host | ||||||
| /// analytics information and user data folder path. | ||||||
| /// </summary> | ||||||
| /// <remarks>Use this constructor to provide context information required during the splash screen | ||||||
| /// startup process, such as analytics data and the location for user-specific files.</remarks> | ||||||
| /// <param name="hostInfo">The analytics information for the host application, or <see langword="null"/> if not available.</param> | ||||||
| /// <param name="userDataFolder">The path to the user data folder. If <see langword="null"/>, an empty string is used.</param> | ||||||
| public SplashScreenStartupContext(HostAnalyticsInfo ?hostInfo, string userDataFolder) | ||||||
| { | ||||||
| HostInfo = hostInfo != null? hostInfo:null; | ||||||
RobertGlobant20 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| HostInfo = hostInfo != null? hostInfo:null; | |
| HostInfo = hostInfo != null ? hostInfo : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
Currentproperty should be nullable (SplashScreenStartupContext?) to match the actual implementation in HostStartup.cs where it's declared asSplashScreenStartupContext? Current.