ConfigurationManager.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. global using static Terminal.Gui.ConfigurationManager;
  2. global using CM = Terminal.Gui.ConfigurationManager;
  3. using System;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using System.Diagnostics;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Reflection;
  10. using System.Text;
  11. using System.Text.Encodings.Web;
  12. using System.Text.Json;
  13. using System.Text.Json.Serialization;
  14. using static Terminal.Gui.SpinnerStyle;
  15. #nullable enable
  16. namespace Terminal.Gui;
  17. /// <summary>
  18. /// Provides settings and configuration management for Terminal.Gui applications.
  19. /// <para>
  20. /// Users can set Terminal.Gui settings on a global or per-application basis by providing JSON formatted configuration files.
  21. /// The configuration files can be placed in at <c>.tui</c> folder in the user's home directory (e.g. <c>C:/Users/username/.tui</c>,
  22. /// or <c>/usr/username/.tui</c>),
  23. /// the folder where the Terminal.Gui application was launched from (e.g. <c>./.tui</c>), or as a resource
  24. /// within the Terminal.Gui application's main assembly.
  25. /// </para>
  26. /// <para>
  27. /// Settings are defined in JSON format, according to this schema:
  28. /// https://gui-cs.github.io/Terminal.Gui/schemas/tui-config-schema.json
  29. /// </para>
  30. /// <para>
  31. /// Settings that will apply to all applications (global settings) reside in files named <c>config.json</c>. Settings
  32. /// that will apply to a specific Terminal.Gui application reside in files named <c>appname.config.json</c>,
  33. /// where <c>appname</c> is the assembly name of the application (e.g. <c>UICatalog.config.json</c>).
  34. /// </para>
  35. /// Settings are applied using the following precedence (higher precedence settings
  36. /// overwrite lower precedence settings):
  37. /// <para>
  38. /// 1. Application configuration found in the users's home directory (<c>~/.tui/appname.config.json</c>) -- Highest precedence
  39. /// </para>
  40. /// <para>
  41. /// 2. Application configuration found in the directory the app was launched from (<c>./.tui/appname.config.json</c>).
  42. /// </para>
  43. /// <para>
  44. /// 3. Application configuration found in the applications's resources (<c>Resources/config.json</c>).
  45. /// </para>
  46. /// <para>
  47. /// 4. Global configuration found in the user's home directory (<c>~/.tui/config.json</c>).
  48. /// </para>
  49. /// <para>
  50. /// 5. Global configuration found in the directory the app was launched from (<c>./.tui/config.json</c>).
  51. /// </para>
  52. /// <para>
  53. /// 6. Global configuration in <c>Terminal.Gui.dll</c>'s resources (<c>Terminal.Gui.Resources.config.json</c>) -- Lowest Precidence.
  54. /// </para>
  55. /// </summary>
  56. public static partial class ConfigurationManager {
  57. private static readonly string _configFilename = "config.json";
  58. internal static readonly JsonSerializerOptions _serializerOptions = new JsonSerializerOptions {
  59. ReadCommentHandling = JsonCommentHandling.Skip,
  60. PropertyNameCaseInsensitive = true,
  61. DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
  62. WriteIndented = true,
  63. Converters = {
  64. // We override the standard Rune converter to support specifying Glyphs in
  65. // a flexible way
  66. new RuneJsonConverter(),
  67. // Override Key to support "Ctrl+Q" format.
  68. new KeyJsonConverter()
  69. },
  70. // Enables Key to be "Ctrl+Q" vs "Ctrl\u002BQ"
  71. Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
  72. };
  73. /// <summary>
  74. /// A dictionary of all properties in the Terminal.Gui project that are decorated with the <see cref="SerializableConfigurationProperty"/> attribute.
  75. /// The keys are the property names pre-pended with the class that implements the property (e.g. <c>Application.UseSystemConsole</c>).
  76. /// The values are instances of <see cref="ConfigProperty"/> which hold the property's value and the
  77. /// <see cref="PropertyInfo"/> that allows <see cref="ConfigurationManager"/> to get and set the property's value.
  78. /// </summary>
  79. /// <remarks>
  80. /// Is <see langword="null"/> until <see cref="Initialize"/> is called.
  81. /// </remarks>
  82. internal static Dictionary<string, ConfigProperty>? _allConfigProperties;
  83. /// <summary>
  84. /// The backing property for <see cref="Settings"/>.
  85. /// </summary>
  86. /// <remarks>
  87. /// Is <see langword="null"/> until <see cref="Reset"/> is called. Gets set to a new instance by
  88. /// deserialization (see <see cref="Load"/>).
  89. /// </remarks>
  90. private static SettingsScope? _settings;
  91. /// <summary>
  92. /// The root object of Terminal.Gui configuration settings / JSON schema. Contains only properties with the <see cref="SettingsScope"/>
  93. /// attribute value.
  94. /// </summary>
  95. public static SettingsScope? Settings {
  96. get {
  97. if (_settings == null) {
  98. throw new InvalidOperationException ("ConfigurationManager has not been initialized. Call ConfigurationManager.Reset() before accessing the Settings property.");
  99. }
  100. return _settings;
  101. }
  102. set {
  103. _settings = value!;
  104. }
  105. }
  106. /// <summary>
  107. /// The root object of Terminal.Gui themes manager. Contains only properties with the <see cref="ThemeScope"/>
  108. /// attribute value.
  109. /// </summary>
  110. public static ThemeManager? Themes => ThemeManager.Instance;
  111. /// <summary>
  112. /// Application-specific configuration settings scope.
  113. /// </summary>
  114. [SerializableConfigurationProperty (Scope = typeof (SettingsScope), OmitClassName = true), JsonPropertyName ("AppSettings")]
  115. public static AppScope? AppSettings { get; set; }
  116. /// <summary>
  117. /// The set of glyphs used to draw checkboxes, lines, borders, etc...See also <seealso cref="Terminal.Gui.GlyphDefinitions"/>.
  118. /// </summary>
  119. [SerializableConfigurationProperty (Scope = typeof (SettingsScope), OmitClassName = true),
  120. JsonPropertyName ("Glyphs")]
  121. public static GlyphDefinitions Glyphs { get; set; } = new GlyphDefinitions ();
  122. /// <summary>
  123. /// Initializes the internal state of ConfigurationManager. Nominally called once as part of application
  124. /// startup to initialize global state. Also called from some Unit Tests to ensure correctness (e.g. Reset()).
  125. /// </summary>
  126. internal static void Initialize ()
  127. {
  128. _allConfigProperties = new Dictionary<string, ConfigProperty> ();
  129. _settings = null;
  130. Dictionary<string, Type> classesWithConfigProps = new Dictionary<string, Type> (StringComparer.InvariantCultureIgnoreCase);
  131. // Get Terminal.Gui.dll classes
  132. var types = from assembly in AppDomain.CurrentDomain.GetAssemblies ()
  133. from type in assembly.GetTypes ()
  134. where type.GetProperties ().Any (prop => prop.GetCustomAttribute (typeof (SerializableConfigurationProperty)) != null)
  135. select type;
  136. foreach (var classWithConfig in types) {
  137. classesWithConfigProps.Add (classWithConfig.Name, classWithConfig);
  138. }
  139. Debug.WriteLine ($"ConfigManager.getConfigProperties found {classesWithConfigProps.Count} classes:");
  140. classesWithConfigProps.ToList ().ForEach (x => Debug.WriteLine ($" Class: {x.Key}"));
  141. foreach (var p in from c in classesWithConfigProps
  142. let props = c.Value.GetProperties (BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).Where (prop =>
  143. prop.GetCustomAttribute (typeof (SerializableConfigurationProperty)) is SerializableConfigurationProperty)
  144. let enumerable = props
  145. from p in enumerable
  146. select p) {
  147. if (p.GetCustomAttribute (typeof (SerializableConfigurationProperty)) is SerializableConfigurationProperty scp) {
  148. if (p.GetGetMethod (true)!.IsStatic) {
  149. // If the class name is omitted, JsonPropertyName is allowed.
  150. _allConfigProperties!.Add (scp.OmitClassName ? ConfigProperty.GetJsonPropertyName (p) : $"{p.DeclaringType?.Name}.{p.Name}", new ConfigProperty {
  151. PropertyInfo = p,
  152. PropertyValue = null
  153. });
  154. } else {
  155. throw new Exception ($"Property {p.Name} in class {p.DeclaringType?.Name} is not static. All SerializableConfigurationProperty properties must be static.");
  156. }
  157. }
  158. }
  159. _allConfigProperties = _allConfigProperties!.OrderBy (x => x.Key).ToDictionary (x => x.Key, x => x.Value, StringComparer.InvariantCultureIgnoreCase);
  160. Debug.WriteLine ($"ConfigManager.Initialize found {_allConfigProperties.Count} properties:");
  161. //_allConfigProperties.ToList ().ForEach (x => Debug.WriteLine ($" Property: {x.Key}"));
  162. AppSettings = new AppScope ();
  163. }
  164. /// <summary>
  165. /// Creates a JSON document with the configuration specified.
  166. /// </summary>
  167. /// <returns></returns>
  168. internal static string ToJson ()
  169. {
  170. Debug.WriteLine ($"ConfigurationManager.ToJson()");
  171. return JsonSerializer.Serialize<SettingsScope> (Settings!, _serializerOptions);
  172. }
  173. internal static Stream ToStream ()
  174. {
  175. var json = JsonSerializer.Serialize<SettingsScope> (Settings!, _serializerOptions);
  176. // turn it into a stream
  177. var stream = new MemoryStream ();
  178. var writer = new StreamWriter (stream);
  179. writer.Write (json);
  180. writer.Flush ();
  181. stream.Position = 0;
  182. return stream;
  183. }
  184. /// <summary>
  185. /// Gets or sets whether the <see cref="ConfigurationManager"/> should throw an exception if it encounters
  186. /// an error on deserialization. If <see langword="false"/> (the default), the error is logged and printed to the
  187. /// console when <see cref="Application.Shutdown"/> is called.
  188. /// </summary>
  189. [SerializableConfigurationProperty (Scope = typeof (SettingsScope))]
  190. public static bool? ThrowOnJsonErrors { get; set; } = false;
  191. internal static StringBuilder jsonErrors = new StringBuilder ();
  192. internal static void AddJsonError (string error)
  193. {
  194. Debug.WriteLine ($"ConfigurationManager: {error}");
  195. jsonErrors.AppendLine (error);
  196. }
  197. /// <summary>
  198. /// Prints any Json deserialization errors that occurred during deserialization to the console.
  199. /// </summary>
  200. public static void PrintJsonErrors ()
  201. {
  202. if (jsonErrors.Length > 0) {
  203. Console.WriteLine ($"Terminal.Gui ConfigurationManager encountered the following errors while deserializing configuration files:");
  204. Console.WriteLine (jsonErrors.ToString ());
  205. }
  206. }
  207. private static void ClearJsonErrors ()
  208. {
  209. jsonErrors.Clear ();
  210. }
  211. /// <summary>
  212. /// Called when the configuration has been updated from a configuration file. Invokes the <see cref="Updated"/>
  213. /// event.
  214. /// </summary>
  215. public static void OnUpdated ()
  216. {
  217. Debug.WriteLine ($"ConfigurationManager.OnApplied()");
  218. Updated?.Invoke (null, new ConfigurationManagerEventArgs ());
  219. }
  220. /// <summary>
  221. /// Event fired when the configuration has been updated from a configuration source.
  222. /// application.
  223. /// </summary>
  224. public static event EventHandler<ConfigurationManagerEventArgs>? Updated;
  225. /// <summary>
  226. /// Resets the state of <see cref="ConfigurationManager"/>. Should be called whenever a new app session
  227. /// (e.g. in <see cref="Application.Init"/> starts. Called by <see cref="Load"/>
  228. /// if the <c>reset</c> parameter is <see langword="true"/>.
  229. /// </summary>
  230. /// <remarks>
  231. ///
  232. /// </remarks>
  233. public static void Reset ()
  234. {
  235. Debug.WriteLine ($"ConfigurationManager.Reset()");
  236. if (_allConfigProperties == null) {
  237. ConfigurationManager.Initialize ();
  238. }
  239. ClearJsonErrors ();
  240. Settings = new SettingsScope ();
  241. ThemeManager.Reset ();
  242. AppSettings = new AppScope ();
  243. // To enable some unit tests, we only load from resources if the flag is set
  244. if (Locations.HasFlag (ConfigLocations.DefaultOnly)) {
  245. Settings.UpdateFromResource (typeof (ConfigurationManager).Assembly, $"Terminal.Gui.Resources.{_configFilename}");
  246. }
  247. Apply ();
  248. ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply ();
  249. AppSettings?.Apply ();
  250. }
  251. /// <summary>
  252. /// Retrieves the hard coded default settings from the Terminal.Gui library implementation. Used in development of
  253. /// the library to generate the default configuration file. Before calling Application.Init, make sure
  254. /// <see cref="Locations"/> is set to <see cref="ConfigLocations.None"/>.
  255. /// </summary>
  256. /// <remarks>
  257. /// <para>
  258. /// This method is only really useful when using ConfigurationManagerTests
  259. /// to generate the JSON doc that is embedded into Terminal.Gui (during development).
  260. /// </para>
  261. /// <para>
  262. /// WARNING: The <c>Terminal.Gui.Resources.config.json</c> resource has setting definitions (Themes)
  263. /// that are NOT generated by this function. If you use this function to regenerate <c>Terminal.Gui.Resources.config.json</c>,
  264. /// make sure you copy the Theme definitions from the existing <c>Terminal.Gui.Resources.config.json</c> file.
  265. /// </para>
  266. /// </remarks>
  267. internal static void GetHardCodedDefaults ()
  268. {
  269. if (_allConfigProperties == null) {
  270. throw new InvalidOperationException ("Initialize must be called first.");
  271. }
  272. Settings = new SettingsScope ();
  273. ThemeManager.GetHardCodedDefaults ();
  274. AppSettings?.RetrieveValues ();
  275. foreach (var p in Settings!.Where (cp => cp.Value.PropertyInfo != null)) {
  276. Settings! [p.Key].PropertyValue = p.Value.PropertyInfo?.GetValue (null);
  277. }
  278. }
  279. /// <summary>
  280. /// Applies the configuration settings to the running <see cref="Application"/> instance.
  281. /// </summary>
  282. public static void Apply ()
  283. {
  284. var settings = false;
  285. var themes = false;
  286. var appSettings = false;
  287. try {
  288. settings = Settings?.Apply () ?? false;
  289. themes = !string.IsNullOrEmpty (ThemeManager.SelectedTheme) && (ThemeManager.Themes? [ThemeManager.SelectedTheme]?.Apply () ?? false);
  290. appSettings = AppSettings?.Apply () ?? false;
  291. } catch (JsonException e) {
  292. if (ThrowOnJsonErrors ?? false) {
  293. throw;
  294. } else {
  295. AddJsonError ($"Error applying Configuration Change: {e.Message}");
  296. }
  297. } finally {
  298. if (settings || themes || appSettings) {
  299. OnApplied ();
  300. }
  301. }
  302. }
  303. /// <summary>
  304. /// Called when an updated configuration has been applied to the
  305. /// application. Fires the <see cref="Applied"/> event.
  306. /// </summary>
  307. public static void OnApplied ()
  308. {
  309. Debug.WriteLine ($"ConfigurationManager.OnApplied()");
  310. Applied?.Invoke (null, new ConfigurationManagerEventArgs ());
  311. // TODO: Refactor ConfigurationManager to not use an event handler for this.
  312. // Instead, have it call a method on any class appropriately attributed
  313. // to update the cached values. See Issue #2871
  314. }
  315. /// <summary>
  316. /// Event fired when an updated configuration has been applied to the
  317. /// application.
  318. /// </summary>
  319. public static event EventHandler<ConfigurationManagerEventArgs>? Applied;
  320. /// <summary>
  321. /// Name of the running application. By default this property is set to the application's assembly name.
  322. /// </summary>
  323. public static string AppName { get; set; } = Assembly.GetEntryAssembly ()?.FullName?.Split (',') [0]?.Trim ()!;
  324. /// <summary>
  325. /// Describes the location of the configuration files. The constants can be
  326. /// combined (bitwise) to specify multiple locations.
  327. /// </summary>
  328. [Flags]
  329. public enum ConfigLocations {
  330. /// <summary>
  331. /// No configuration will be loaded.
  332. /// </summary>
  333. /// <remarks>
  334. /// Used for development and testing only. For Terminal,Gui to function properly, at least
  335. /// <see cref="DefaultOnly"/> should be set.
  336. /// </remarks>
  337. None = 0,
  338. /// <summary>
  339. /// Global configuration in <c>Terminal.Gui.dll</c>'s resources (<c>Terminal.Gui.Resources.config.json</c>) -- Lowest Precidence.
  340. /// </summary>
  341. DefaultOnly,
  342. /// <summary>
  343. /// This constant is a combination of all locations
  344. /// </summary>
  345. All = -1
  346. }
  347. /// <summary>
  348. /// Gets and sets the locations where <see cref="ConfigurationManager"/> will look for config files.
  349. /// The value is <see cref="ConfigLocations.All"/>.
  350. /// </summary>
  351. public static ConfigLocations Locations { get; set; } = ConfigLocations.All;
  352. /// <summary>
  353. /// Loads all settings found in the various configuration storage locations to
  354. /// the <see cref="ConfigurationManager"/>. Optionally,
  355. /// resets all settings attributed with <see cref="SerializableConfigurationProperty"/> to the defaults.
  356. /// </summary>
  357. /// <remarks>
  358. /// Use <see cref="Apply"/> to cause the loaded settings to be applied to the running application.
  359. /// </remarks>
  360. /// <param name="reset">If <see langword="true"/> the state of <see cref="ConfigurationManager"/> will
  361. /// be reset to the defaults.</param>
  362. public static void Load (bool reset = false)
  363. {
  364. Debug.WriteLine ($"ConfigurationManager.Load()");
  365. if (reset) {
  366. Reset ();
  367. }
  368. // LibraryResources is always loaded by Reset
  369. if (Locations == ConfigLocations.All) {
  370. var embeddedStylesResourceName = Assembly.GetEntryAssembly ()?
  371. .GetManifestResourceNames ().FirstOrDefault (x => x.EndsWith (_configFilename));
  372. if (string.IsNullOrEmpty (embeddedStylesResourceName)) {
  373. embeddedStylesResourceName = _configFilename;
  374. }
  375. Settings = Settings?
  376. // Global current directory
  377. .Update ($"./.tui/{_configFilename}")?
  378. // Global home directory
  379. .Update ($"~/.tui/{_configFilename}")?
  380. // App resources
  381. .UpdateFromResource (Assembly.GetEntryAssembly ()!, embeddedStylesResourceName!)?
  382. // App current directory
  383. .Update ($"./.tui/{AppName}.{_configFilename}")?
  384. // App home directory
  385. .Update ($"~/.tui/{AppName}.{_configFilename}");
  386. }
  387. }
  388. /// <summary>
  389. /// Returns an empty Json document with just the $schema tag.
  390. /// </summary>
  391. /// <returns></returns>
  392. public static string GetEmptyJson ()
  393. {
  394. var emptyScope = new SettingsScope ();
  395. emptyScope.Clear ();
  396. return JsonSerializer.Serialize<SettingsScope> (emptyScope, _serializerOptions);
  397. }
  398. /// <summary>
  399. /// System.Text.Json does not support copying a deserialized object to an existing instance.
  400. /// To work around this, we implement a 'deep, memberwise copy' method.
  401. /// </summary>
  402. /// <remarks>
  403. /// TOOD: When System.Text.Json implements `PopulateObject` revisit
  404. /// https://github.com/dotnet/corefx/issues/37627
  405. /// </remarks>
  406. /// <param name="source"></param>
  407. /// <param name="destination"></param>
  408. /// <returns><paramref name="destination"/> updated from <paramref name="source"/></returns>
  409. internal static object? DeepMemberwiseCopy (object? source, object? destination)
  410. {
  411. if (destination == null) {
  412. throw new ArgumentNullException (nameof (destination));
  413. }
  414. if (source == null) {
  415. return null!;
  416. }
  417. if (source.GetType () == typeof (SettingsScope)) {
  418. return ((SettingsScope)destination).Update ((SettingsScope)source);
  419. }
  420. if (source.GetType () == typeof (ThemeScope)) {
  421. return ((ThemeScope)destination).Update ((ThemeScope)source);
  422. }
  423. if (source.GetType () == typeof (AppScope)) {
  424. return ((AppScope)destination).Update ((AppScope)source);
  425. }
  426. // If value type, just use copy constructor.
  427. if (source.GetType ().IsValueType || source.GetType () == typeof (string)) {
  428. return source;
  429. }
  430. // Dictionary
  431. if (source.GetType ().IsGenericType && source.GetType ().GetGenericTypeDefinition ().IsAssignableFrom (typeof (Dictionary<,>))) {
  432. foreach (var srcKey in ((IDictionary)source).Keys) {
  433. if (srcKey is string) {
  434. }
  435. if (((IDictionary)destination).Contains (srcKey))
  436. ((IDictionary)destination) [srcKey] = DeepMemberwiseCopy (((IDictionary)source) [srcKey], ((IDictionary)destination) [srcKey]);
  437. else {
  438. ((IDictionary)destination).Add (srcKey, ((IDictionary)source) [srcKey]);
  439. }
  440. }
  441. return destination;
  442. }
  443. // ALl other object types
  444. var sourceProps = source?.GetType ().GetProperties ().Where (x => x.CanRead).ToList ();
  445. var destProps = destination?.GetType ().GetProperties ().Where (x => x.CanWrite).ToList ()!;
  446. foreach (var (sourceProp, destProp) in
  447. from sourceProp in sourceProps
  448. where destProps.Any (x => x.Name == sourceProp.Name)
  449. let destProp = destProps.First (x => x.Name == sourceProp.Name)
  450. where destProp.CanWrite
  451. select (sourceProp, destProp)) {
  452. var sourceVal = sourceProp.GetValue (source);
  453. var destVal = destProp.GetValue (destination);
  454. if (sourceVal != null) {
  455. if (destVal != null) {
  456. // Recurse
  457. destProp.SetValue (destination, DeepMemberwiseCopy (sourceVal, destVal));
  458. } else {
  459. destProp.SetValue (destination, sourceVal);
  460. }
  461. }
  462. }
  463. return destination!;
  464. }
  465. //public class ConfiguraitonLocation
  466. //{
  467. // public string Name { get; set; } = string.Empty;
  468. // public string? Path { get; set; }
  469. // public async Task<SettingsScope> UpdateAsync (Stream stream)
  470. // {
  471. // var scope = await JsonSerializer.DeserializeAsync<SettingsScope> (stream, serializerOptions);
  472. // if (scope != null) {
  473. // ConfigurationManager.Settings?.UpdateFrom (scope);
  474. // return scope;
  475. // }
  476. // return new SettingsScope ();
  477. // }
  478. //}
  479. //public class StreamConfiguration {
  480. // private bool _reset;
  481. // public StreamConfiguration (bool reset)
  482. // {
  483. // _reset = reset;
  484. // }
  485. // public StreamConfiguration UpdateAppResources ()
  486. // {
  487. // if (Locations.HasFlag (ConfigLocations.AppResources)) LoadAppResources ();
  488. // return this;
  489. // }
  490. // public StreamConfiguration UpdateAppDirectory ()
  491. // {
  492. // if (Locations.HasFlag (ConfigLocations.AppDirectory)) LoadAppDirectory ();
  493. // return this;
  494. // }
  495. // // Additional update methods for each location here
  496. // private void LoadAppResources ()
  497. // {
  498. // // Load AppResources logic here
  499. // }
  500. // private void LoadAppDirectory ()
  501. // {
  502. // // Load AppDirectory logic here
  503. // }
  504. //}
  505. }