NStack.SDK
1.0.0
See the version list below for details.
dotnet add package NStack.SDK --version 1.0.0
NuGet\Install-Package NStack.SDK -Version 1.0.0
<PackageReference Include="NStack.SDK" Version="1.0.0" />
<PackageVersion Include="NStack.SDK" Version="1.0.0" />
<PackageReference Include="NStack.SDK" />
paket add NStack.SDK --version 1.0.0
#r "nuget: NStack.SDK, 1.0.0"
#:package NStack.SDK@1.0.0
#addin nuget:?package=NStack.SDK&version=1.0.0
#tool nuget:?package=NStack.SDK&version=1.0.0
NStack .NET Standard SDK
Use this SDK to interact with NStack. This SDK contains injectable services to get translations etc. from NStack.
Configuration
The configuration is stored in the class NStackConfiguration which have three properties:
- ApiKey
- ApplicationId
- BaseUrl
All information can be found in the NStack portal
Interfaces
Every service is implemented using the interface approach to make dependency injection as smooth as possible.
INStackRepository
This interface handles the REST communication with the NStack server. The built in implementation of the interface is NStackRepository which takes NStackConfiguration as a constructor parameter. The exposed functions are for use by the service layer.
INStackLocalizeService
This interface handles all communication regarding translations.
GetLanguages
This function returns all available languages for the platform provided as parameter. The format returned is DataWrapper<List<ResourceData>>.
Parameters:
| Name | Type |
|---|---|
| platform | NStackPlatform (enum) |
ResourceData
| Property name | Type |
|---|---|
| Id | int |
| Url | string |
| LastUpdatedAt | DateTime |
| ShouldUpdate | bool |
| Language | Language |
Language
| Property name | Type |
|---|---|
| Id | int |
| Name | string |
| Locale | string |
| LanguageDirection | LanguageDirection (enum) |
| IsDefault | bool |
| IsBestFit | bool |
GetResource
This function returns translations for a language. The function by default returns a ResourceItem, but takes a type if you have a class which inherits ResourceItem to get your language file strongly typed.
Parameters
| Property name | Type |
|---|---|
| id | int |
ResourceItem
ResourceItem is an implementation of ConcurrentDictionary<string, ResourceInnerItem> which can be extended to get strongly typed sections for your translation. The Translation generator tool can be used to generate these files automatically.
This class holds the translation sections and can be used by either extending the class or just use the class as is as a normal dictionary e.g. item["mySection"].
ResourceInnerItem
ResourceInnerItem is an implemenation of ConcurrentDictionary<string, string> which can be extended in the same manner as ResourceItem. This class holds the actual translations and can be used by either extending the class or just use the class as is as a normal dictionary e.g. innerItem["myTranslation"].
DI setup
The SDK is built with DI support in mind and can be quickly set up in your startup.cs file in ConfigureServices:
services.AddSingleton<NStackConfiguration>(r => new NStackConfiguration
{
ApiKey = "MyApiKey",
ApplicationId = "MyApplicationId",
BaseUrl = "MyBaseUrl"
});
services.AddTransient<INStackRepository, NStackRepository>();
services.AddTransient<INStackLocalizeService, NStackLocalizeService>();
Best practice is to not hard code the configuration values but to fetch them from your application settings.
Translation generator
The translation generator is a tool which can access your NStack translation and generate C# classes based on the JSON response from a specified resource.
Currently the tool is only available for use in Windows. The tool is downloaded along with the NuGet package in packages/NStack.SDK/{version}/NStackTranslationGenerator/NStackTranslationGenerator.exe.
Parameters
The parameters are listed below and can also be viewed by using the --help for the tool
| Short name | Long name | Required | Default value | Description |
|---|---|---|---|---|
| -c | --className | Translation | The name of the class holding the translation sections | |
| -i | --applicationId | ✔️ | The ID for you NStack application | |
| -k | --apiKey | ✔️ | The API key for your NStack integration | |
| -n | --namespace | ✔️ | The namespace for the created classes | |
| -o | --output | ./output | The output folder for the generated classes | |
| -s | --showJson | false | Show the fetched JSON from NStack in the console? | |
| -t | --translationId | ✔️ | The ID of the translation to generate the classes from | |
| -u | --url | https://nstack.io | The base url of the NStack service |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.3)
- RestSharp (>= 106.11.4)
- System.Text.Json (>= 4.7.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.