NStack.SDK 1.0.0

Suggested Alternatives

Monstarlab.NStack.SDK

There is a newer version of this package available.
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
                    
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="NStack.SDK" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NStack.SDK" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="NStack.SDK" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NStack.SDK --version 1.0.0
                    
#r "nuget: NStack.SDK, 1.0.0"
                    
#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.
#:package NStack.SDK@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NStack.SDK&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=NStack.SDK&version=1.0.0
                    
Install as a Cake Tool

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&lt;List&lt;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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.