Custom NMEA messages can be registered for parsing as well.
To create a new message, add the NmeaMessageType attribute to the class, and declare the 5-character message type.
*Note: You can use `--` as the first two characters to make it independent of the Talker Type.*
Next ensure you have a constructor that takes the `TypeName` string parameter first, and a second `string[]` parameter that will contain all the message values:
Next register this with the NMEA Parser using either:
```cs
NmeaMessage.RegisterAssembly(typeof(CustomMessage).Assembly); //Registers all types in the provided assembly
NmeaMessage.RegisterMessage(typeof(CustomMessage).GetTypeInfo()); //Registers a single NMEA message
```
Note that these methods will throw if the NMEA type has already been registers (there's an overload where you can declare the `replace` parameter to `true` to overwrite already registered messages.
Next you should be able to test this method using the Parse method:
```cs
var input = "$PTEST,TEST*7C";
var msg = NmeaMessage.Parse(input);
```
# Creating a multi-sentence message
A NMEA message cannot exceed 82 characters, so often messages are split into multiple sentences. To create a custom multi message, either implement `IMultiSentenceMessage` or simply subclass `NmeaMultiSentenceMessage`.
```cs
[NmeaMessageType("PTST2")]
private class CustomMultiMessage : NmeaMultiSentenceMessage, IMultiSentenceMessage
{
public CustomMultiMessage(string type, string[] parameters) : base(type, parameters)
{
}
public string Id { get; private set; }
public List<string> Values { get; } = new List<string>();
Note that the message is parsed in the `ParseSentences` method, and not the constructor. Also note that the talkerType is parsed to you, because multi-sentence messages allows a mix of talker types, if you use the `--` prefex in the NMEA type.
Next we can parse the two messages and have the second one be appended to the first one: