MqttTopicBuilder 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MqttTopicBuilder --version 2.2.0                
NuGet\Install-Package MqttTopicBuilder -Version 2.2.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="MqttTopicBuilder" Version="2.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MqttTopicBuilder --version 2.2.0                
#r "nuget: MqttTopicBuilder, 2.2.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.
// Install MqttTopicBuilder as a Cake Addin
#addin nuget:?package=MqttTopicBuilder&version=2.2.0

// Install MqttTopicBuilder as a Cake Tool
#tool nuget:?package=MqttTopicBuilder&version=2.2.0                

MqttTopicBuilder

Category Status
Package NuGet Badge
Quality CodeFactor
CI / CD Build Deployment

📮 MqttTopicBuilder is a tool to build valid and verified MQTT topics

The project is built using .NET Standard 2.0 (compatible with .NET Core 2 and .NET Framework 4.6.1)

Installation

You can find this projet on NuGet.

To install it from the command line, use:
~$ dotnet add package MqttTopicBuilder

or, from the package manager:
Install-Package MqttTopicBuilder

Usage

More detailed instructions and documentation are available here
For changelog, see the changelog

Using a custom builder, MqttTopicBuilder allows you to build topics and ensure their validity regarding the way you are planning to use them.

var subscribeTo = new TopicBuilder(TopicConsumer.Subscriber)
    .AddTopic("Hello")
    .AddTopic("From")
    .AddTopics("Mqtt", "Topic", "Builder")
    .AddMultiLevelWildcard()
    .Build();

Console.WriteLine(subscribeTo);
// -> "Hello/From/Mqtt/Topic/Builder/#"

var publishTop = new TopicBuilder(TopicConsumer.Publisher)
    .AddTopic("Hello")
    .AddTopic("From")
    .AddTopics("Mqtt", "Topic", "Builder")
    .AddMultiLevelWildcard()
    .Build();
// Will throw an exception since wildcards are not allowed when publishing
// on a topic

The built object is a Topic object. It can be used to both access the topic but also gather informations about it such as its level.

var topic = new TopicBuilder(TopicConsumer.Subscriber)
    .AddTopic("Hello")
    .AddTopic("World")
    .Build();

Console.WriteLine(topic.Value);
// -> "Hello/World"

Console.WriteLine(topic.Levels);
// -> 2

Topics can also be built using the regular constructor or the extension method:

var topic = Topic.FromString("Hello/World");
// or: var topic = (Topic) "Hello/World";

Console.WriteLine(topic.Value);
// -> "Hello/World"

Console.WriteLine(topic.Levels);
// -> 2

Topic integrity can also be checked using the TopicValidator methods

TopicValidator.ValidateTopic("a/wrong/#/Topic");
// Will throw an exception since no topic is allowed after '#'

"wrong+Topic".ValidateTopicForAppending();
// Will throw an exception since '+' is not allowed in a topic

Contributions

All contributions are welcome, please feel free to suggest pull requests ! You can read more about it in the CONTRIBUTING.md.

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. 
.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.
  • .NETStandard 2.0

    • 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.