Skip to content

Commit

Permalink
feat: Simplified implementation of MRT Core ResourceLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Apr 15, 2024
1 parent d83f220 commit ec0dc35
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Windows.ApplicationModel.Resources
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented]
#endif
public partial class ResourceLoader
{
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public ResourceLoader(string fileName)
{
Expand All @@ -24,15 +24,15 @@ public ResourceLoader(string fileName, string resourceMap)
}
#endif
// Forced skipping of method Microsoft.Windows.ApplicationModel.Resources.ResourceLoader.ResourceLoader(string, string)
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public ResourceLoader()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.Windows.ApplicationModel.Resources.ResourceLoader", "ResourceLoader.ResourceLoader()");
}
#endif
// Forced skipping of method Microsoft.Windows.ApplicationModel.Resources.ResourceLoader.ResourceLoader()
#if __ANDROID__ || __IOS__ || IS_UNIT_TESTS || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "IS_UNIT_TESTS", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string GetString(string resourceId)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using WinRTResourceLoader = global::Windows.ApplicationModel.Resources.ResourceLoader;

namespace Microsoft.Windows.ApplicationModel.Resources;

/// <summary>
/// Provides simplified access to app resources such as app UI strings.
/// </summary>
public partial class ResourceLoader
{
private readonly WinRTResourceLoader _resourceLoader;

/// <summary>
/// Constructs a new ResourceLoader object for the "Resources" subtree of the currently running app's main ResourceMap.
/// </summary>
public ResourceLoader() => _resourceLoader = new();

/// <summary>
/// Constructs a new ResourceLoader object for the specified ResourceMap.
/// </summary>
/// <param name="fileName">
/// The resource identifier of the ResourceMap that the new resource loader
/// uses for unqualified resource references. It can then retrieve resources
/// relative to those references.
/// </param>
public ResourceLoader(string fileName) => _resourceLoader = new(fileName);

/// <summary>
/// Returns the most appropriate string value of a resource, specified by resource identifier.
/// </summary>
/// <param name="resourceId">The resource identifier of the resource to be resolved.</param>
/// <returns>The most appropriate string value of the specified resource for the default ResourceContext.</returns>
public string GetString(string resourceId) => _resourceLoader.GetString(resourceId);
}
Loading

0 comments on commit ec0dc35

Please sign in to comment.