Skip to content

Commit 9dd1b6b

Browse files
committed
Add NuGet readme and version up.
1 parent 72bdeea commit 9dd1b6b

File tree

3 files changed

+143
-2
lines changed

3 files changed

+143
-2
lines changed

nuget/Mntone.RWinRT.nuspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1111
<description>R/WinRT is ease-to-use resources access for MRTCore.</description>
1212
<copyright>Copyright © 2023 mntone</copyright>
13+
<readme>docs\readme.md</readme>
1314
<language>en-US</language>
1415
<tags>Win Windows WinRT WindowsRuntime WinUI WindowsUI WinAppSDK WindowsAppSDK mntone Cpp C++ C# CSharp MRTCore Resources resw Culture Globalization Localization i18n</tags>
16+
<repository type="git" url="https://github.com/mntone/RWinRT.git" branch="main" />
1517
</metadata>
1618
<files>
17-
<!--<file src="readme.txt" />-->
19+
<file target="docs" src="readme.md" />
1820
<file target="license.txt" src="..\LICENSE.txt" />
1921

2022
<file target="build" src="Mntone.RWinRT.props" />

nuget/readme.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# R/WinRT for Windows App SDK
2+
3+
R/WinRT is ease-to-use resources access for the MRTCore resource files.
4+
5+
[Source code][source] | [Package (NuGet)][package]
6+
7+
## Getting started
8+
9+
### Install the package
10+
11+
Install the R/WinRT with [NuGet][nuget]:
12+
13+
```cmd
14+
nuget install Mntone.RWinRT
15+
```
16+
17+
## Examples
18+
19+
### [C#/WinRT] Get the resource
20+
21+
Define "Hello, World!" as the key "HelloWorld" in Resources.lang-en-US.resw.
22+
23+
```cs
24+
using System;
25+
26+
namespace RWinRTCsTest
27+
{
28+
class Program
29+
{
30+
static void Main(string[] args)
31+
{
32+
var text = R.HelloWorld.Value;
33+
Console.WriteLine(text); // [Output] Hello, World!
34+
}
35+
}
36+
}
37+
```
38+
39+
### [C#/WinRT] Get the formatted resource
40+
41+
Define "I have {0} apples!" as the key "IHaveNApples" in Resources.lang-en-US.resw.
42+
43+
```cs
44+
using System;
45+
46+
namespace RWinRTCsTest
47+
{
48+
class Program
49+
{
50+
static void Main(string[] args)
51+
{
52+
var count = 4;
53+
var fmtText = R.IHaveNApples.Format(4);
54+
Console.WriteLine(fmtText); // [Output] I have 4 apples!
55+
}
56+
}
57+
}
58+
```
59+
60+
### [C#/WinRT] Change current language
61+
62+
Define "日本語 (Japanese)" as the key "CurrentLanguage" in Resources.lang-ja-JP.resw.
63+
64+
```cs
65+
using System;
66+
67+
namespace RWinRTCsTest
68+
{
69+
class Program
70+
{
71+
static void Main(string[] args)
72+
{
73+
RWinRT.ResourceManager.ChangeLanguage("ja-JP");
74+
75+
var language = R.CurrentLanguage.Value;
76+
Console.WriteLine(language); // [Output] 日本語 (Japanese)
77+
}
78+
}
79+
}
80+
```
81+
82+
### [C++/WinRT] Get the resource
83+
84+
Define "Hello, World!" as the key "HelloWorld" in Resources.lang-en-US.resw.
85+
86+
```cpp
87+
#include <iostream>
88+
89+
#include "res.g.h"
90+
91+
int main() {
92+
ResourceManager<R> manager;
93+
ResourceContext<R> context { manager.Context() };
94+
winrt::hstring text { context.Value<R::HelloWorld>() }; // [Output] Hello, World!
95+
std::cout << text << std::endl;
96+
return 0;
97+
}
98+
```
99+
100+
### [C++/WinRT] Get the formatted resource
101+
102+
Define "I have %d apples!" as the key "IHaveNApples" in Resources.lang-en-US.resw.
103+
104+
```cpp
105+
#include <iostream>
106+
107+
#include "res.g.h"
108+
109+
int main() {
110+
ResourceManager<R> manager;
111+
ResourceContext<R> context { manager.Context() };
112+
int count { 4 };
113+
winrt::hstring fmtText { context.Format<R::IHaveNApples>(count) }; // [Output] I have 4 apples!
114+
std::cout << fmtText << std::endl;
115+
return 0;
116+
}
117+
```
118+
119+
### [C++/WinRT] Change current language
120+
121+
Define "日本語 (Japanese)" as the key "CurrentLanguage" in Resources.lang-ja-JP.resw.
122+
123+
```cpp
124+
#include <iostream>
125+
126+
#include "res.g.h"
127+
128+
int main() {
129+
ResourceManager<R> manager;
130+
ResourceContext<R> context { manager.Context(L"ja-JP") };
131+
winrt::hstring text { context.Value<R::CurrentLanguage>() }; // [Output] 日本語 (Japanese)
132+
std::cout << text << std::endl;
133+
return 0;
134+
}
135+
```
136+
137+
[source]: https://github.com/mntone/RWinRT/tree/main/src
138+
[package]: https://www.nuget.org/packages/Mntone.RWinRT
139+
[nuget]: https://www.nuget.org/

src/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<RWinRTCopyright>Copyright (c) 2023 $(RWinRTAuthor). All rights reserved.</RWinRTCopyright>
66
<RWinRTVersionMajor>0</RWinRTVersionMajor>
77
<RWinRTVersionMinor>0</RWinRTVersionMinor>
8-
<RWinRTVersionPatch>3</RWinRTVersionPatch>
8+
<RWinRTVersionPatch>4</RWinRTVersionPatch>
99
<RWinRTVersionBuild Condition="$(AngelVersionBuild)==''">$([System.DateTime]::Now.ToString(`yyyy`))</RWinRTVersionBuild>
1010
<RWinRTVersionRevision Condition="$(AngelVersionRevision)==''">$([System.DateTime]::Now.ToString(`MMdd`))</RWinRTVersionRevision>
1111
<RWinRTVersionPreRelease>beta</RWinRTVersionPreRelease>

0 commit comments

Comments
 (0)