Skip to content

Commit 6bc8c76

Browse files
authored
Codebase: Added AppEnvironment enum (#12025)
1 parent 3f29e4e commit 6bc8c76

File tree

3 files changed

+56
-2
lines changed

3 files changed

+56
-2
lines changed

src/Files.App/App.xaml.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Files.App.ViewModels;
2121
using Files.App.ViewModels.Settings;
2222
using Files.App.Views;
23+
using Files.Backend.Enums;
2324
using Files.Backend.Services;
2425
using Files.Backend.Services.Settings;
2526
using Files.Backend.Services.SizeProvider;
@@ -73,6 +74,7 @@ public partial class App : Application
7374

7475
public static string AppVersion = $"{Package.Current.Id.Version.Major}.{Package.Current.Id.Version.Minor}.{Package.Current.Id.Version.Build}.{Package.Current.Id.Version.Revision}";
7576
public static string LogoPath;
77+
public static AppEnvironment AppEnv;
7678

7779
/// <summary>
7880
/// Initializes the singleton application object. This is the first line of authored code
@@ -83,8 +85,8 @@ public App()
8385
UnhandledException += OnUnhandledException;
8486
TaskScheduler.UnobservedTaskException += OnUnobservedException;
8587
InitializeComponent();
86-
LogoPath = Package.Current.DisplayName == "Files - Dev" ? Constants.AssetPaths.DevLogo
87-
: (Package.Current.DisplayName == "Files (Preview)" ? Constants.AssetPaths.PreviewLogo : Constants.AssetPaths.StableLogo);
88+
89+
(AppEnv, LogoPath) = EnvHelpers.GetAppEnvironmentAndLogo();
8890
}
8991

9092
private static void EnsureSettingsAndConfigurationAreBootstrapped()
@@ -173,6 +175,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
173175
// Initialize MainWindow here
174176
EnsureWindowIsInitialized();
175177
host = Host.CreateDefaultBuilder()
178+
.UseEnvironment(AppEnv.ToString())
176179
.ConfigureLogging(builder =>
177180
builder
178181
.AddProvider(new FileLoggerProvider(logPath))

src/Files.App/Helpers/EnvHelpers.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Files.Backend.Enums;
2+
using Microsoft.Extensions.Hosting;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using Windows.ApplicationModel;
9+
10+
namespace Files.App.Helpers
11+
{
12+
public static class EnvHelpers
13+
{
14+
15+
public static (AppEnvironment, string) GetAppEnvironmentAndLogo()
16+
{
17+
18+
19+
var env =
20+
#if STORE
21+
AppEnvironment.Store;
22+
#elif PREVIEW
23+
AppEnvironment.Preview;
24+
#elif STABLE
25+
AppEnvironment.Stable;
26+
#else
27+
AppEnvironment.Dev;
28+
#endif
29+
30+
var path = env switch
31+
{
32+
AppEnvironment.Dev => Constants.AssetPaths.DevLogo,
33+
AppEnvironment.Preview => Constants.AssetPaths.PreviewLogo,
34+
_ => Constants.AssetPaths.StableLogo,
35+
};
36+
37+
return (env, path);
38+
}
39+
}
40+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+

2+
namespace Files.Backend.Enums
3+
{
4+
public enum AppEnvironment
5+
{
6+
Dev,
7+
Stable,
8+
Store,
9+
Preview
10+
}
11+
}

0 commit comments

Comments
 (0)