Mntone.RWinRT
0.0.4-beta
dotnet add package Mntone.RWinRT --version 0.0.4-beta
NuGet\Install-Package Mntone.RWinRT -Version 0.0.4-beta
<PackageReference Include="Mntone.RWinRT" Version="0.0.4-beta" />
paket add Mntone.RWinRT --version 0.0.4-beta
#r "nuget: Mntone.RWinRT, 0.0.4-beta"
// 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.
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;
}
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 | 114 | 1/28/2023 |
0.0.3-beta | 106 | 1/26/2023 |
0.0.2-alpha | 110 | 1/21/2023 |
0.0.1-alpha | 105 | 1/20/2023 |