MRTSharp 1.0.0

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

// Install MRTSharp as a Cake Tool
#tool nuget:?package=MRTSharp&version=1.0.0

MRT#

MRT# is a fast multi-threaded MRT parser library written in C#.

Example Usage

The entrypoint of the parser is the Run static method of the MRTParser class.

using MRTSharp;
using System.IO;

class Program
{
    static void Main()
    {
        FileInfo file = new FileInfo(@"path-to-mrt-file");

        MRTParser.Run(file, (mrtEntry) =>
        {
            // Do something with the mrtEntry
        });
    }
}

Other options

Input file options

MRTParser.Run method has different signatures. It accepts FileInfo, IEnumerable<FileInfo> or DirectoryInfo as parameter. Using the DirectoryInfo version, all files contained in the specified directory are processed, ignoring subdirectories and their files.

Processing options

All the MRTParser.Run methods that accept more than one file (IEnumerable<FileInfo> or DirectoryInfo) have an optional boolean parameter multithreaded (default=true) that can be used to disable the multithreaded parsing.

Output options

MRTParser.Run method has two signatures. The first one, only takes a single parameter (FileInfo, IEnumerable<FileInfo> or DirectoryInfo) and returns a List. The second one, takes two parameters: FileInfo/IEnumerable<FileInfo>/DirectoryInfo, and a callback (like in the above example) that enables the user to further process MRT records.

Moreover, both the one and two parameter versions of the method can be invoked with the diamond operator <T>. Using <T>, it is possible to specify the type of the returned objects. All the objects that cannot be downcasted to T are automatically discarded. T can be one of the following: MRTEntry (default, if not specified), TableDumpRIBRecord, BGP4MPEntry, BGP4MPMessage, or BGP4MPStateChange.

Logging

MRT# logs on the DEBUG channel if an MRT file is corrupted or some fields cannot be parsed.

You can connect your own logger, that MUST be an instance of a Microsoft.Extensions.Logging.ILogger implementation, using the SetLogger static method of MRTParser before calling the Run method.

MRTParser.SetLogger(yourILoggerVariable);

MRTParser.Run(...);
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
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.

Version Downloads Last updated
1.0.7 89 3/4/2024
1.0.6 163 7/27/2023
1.0.5 1,350 5/4/2022
1.0.4 392 3/29/2022
1.0.3 393 3/29/2022
1.0.2 263 12/20/2021
1.0.1 304 3/31/2021
1.0.0 321 2/22/2021