Mntone.RWinRT 0.0.4-beta

This is a prerelease version of Mntone.RWinRT.
dotnet add package Mntone.RWinRT --version 0.0.4-beta
NuGet\Install-Package Mntone.RWinRT -Version 0.0.4-beta
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Mntone.RWinRT" Version="0.0.4-beta" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mntone.RWinRT --version 0.0.4-beta
#r "nuget: Mntone.RWinRT, 0.0.4-beta"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Mntone.RWinRT as a Cake Addin
#addin nuget:?package=Mntone.RWinRT&version=0.0.4-beta&prerelease

// Install Mntone.RWinRT as a Cake Tool
#tool nuget:?package=Mntone.RWinRT&version=0.0.4-beta&prerelease

R/WinRT for Windows App SDK

R/WinRT is ease-to-use resources access for the MRTCore resource files.

Source code | Package (NuGet)

Getting started

Install the package

Install the R/WinRT with NuGet:

nuget install Mntone.RWinRT

Examples

[C#/WinRT] Get the resource

Define "Hello, World!" as the key "HelloWorld" in Resources.lang-en-US.resw.

using System;

namespace RWinRTCsTest
{
  class Program
  {
    static void Main(string[] args)
    {
      var text = R.HelloWorld.Value;
      Console.WriteLine(text); // [Output] Hello, World!
    }
  }
}

[C#/WinRT] Get the formatted resource

Define "I have {0} apples!" as the key "IHaveNApples" in Resources.lang-en-US.resw.

using System;

namespace RWinRTCsTest
{
  class Program
  {
    static void Main(string[] args)
    {
      var count = 4;
      var fmtText = R.IHaveNApples.Format(4);
      Console.WriteLine(fmtText); // [Output] I have 4 apples!
    }
  }
}

[C#/WinRT] Change current language

Define "日本語 (Japanese)" as the key "CurrentLanguage" in Resources.lang-ja-JP.resw.

using System;

namespace RWinRTCsTest
{
  class Program
  {
    static void Main(string[] args)
    {
      RWinRT.ResourceManager.ChangeLanguage("ja-JP");

      var language = R.CurrentLanguage.Value;
      Console.WriteLine(language); // [Output] 日本語 (Japanese)
    }
  }
}

[C++/WinRT] Get the resource

Define "Hello, World!" as the key "HelloWorld" in Resources.lang-en-US.resw.

#include <iostream>

#include "res.g.h"

int main() {
  ResourceManager<R> manager;
  ResourceContext<R> context { manager.Context() };
  winrt::hstring text { context.Value<R::HelloWorld>() }; // [Output] Hello, World!
  std::cout << text << std::endl;
  return 0;
}

[C++/WinRT] Get the formatted resource

Define "I have %d apples!" as the key "IHaveNApples" in Resources.lang-en-US.resw.

#include <iostream>

#include "res.g.h"

int main() {
  ResourceManager<R> manager;
  ResourceContext<R> context { manager.Context() };
  int count { 4 };
  winrt::hstring fmtText { context.Format<R::IHaveNApples>(count) }; // [Output] I have 4 apples!
  std::cout << fmtText << std::endl;
  return 0;
}

[C++/WinRT] Change current language

Define "日本語 (Japanese)" as the key "CurrentLanguage" in Resources.lang-ja-JP.resw.

#include <iostream>

#include "res.g.h"

int main() {
  ResourceManager<R> manager;
  ResourceContext<R> context { manager.Context(L"ja-JP") };
  winrt::hstring text { context.Value<R::CurrentLanguage>() }; // [Output] 日本語 (Japanese)
  std::cout << text << std::endl;
  return 0;
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.4-beta 98 1/28/2023
0.0.3-beta 94 1/26/2023
0.0.2-alpha 97 1/21/2023
0.0.1-alpha 96 1/20/2023