MqttTopicBuilder 2.3.0

dotnet add package MqttTopicBuilder --version 2.3.0
NuGet\Install-Package MqttTopicBuilder -Version 2.3.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.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MqttTopicBuilder --version 2.3.0
#r "nuget: MqttTopicBuilder, 2.3.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.3.0

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

MqttTopicBuilder

Build valid and verified MQTT topics

MqttTopicBuilder is a small library without any dependency that can help you to enforce the validity of your MQTT topics by using the provided builder.

Installation

You can find this projet on NuGet.

From the command line:

dotnet add package MqttTopicBuilder

From the package manager:

Install-Package MqttTopicBuilder

Usage

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 object built 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 is compatible. 
.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.
  • .NETStandard 2.1

    • 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
2.3.0 25,800 5/22/2022
2.2.0 417 8/26/2020
2.1.0 394 7/26/2020
2.0.2 372 6/29/2020
1.2.0 587 2/23/2020
1.1.1 522 2/16/2020
1.1.0 500 2/13/2020
1.0.2 576 2/11/2020
1.0.1 522 2/10/2020
1.0.0 539 2/10/2020