in codegen/src/Azure.Iot.Operations.ProtocolCompiler/SchemaGenerator/TopicCollisionDetector.cs [30:64]
public void Check(DTInterfaceInfo dtInterface, IEnumerable<string> names, int mqttVersion)
{
if (dtInterface.SupplementalProperties.TryGetValue(string.Format(topicPropertyPattern, mqttVersion), out object? topicObj) && topicObj is string topic)
{
if (!combineWhenNoName && !topic.Contains(nameToken) && names.Count() > 1)
{
throw new Exception($"Interface {dtInterface.Id} has {topicType} topic \"{topic}\", which must include token \"{nameToken}\" because there is more than one {topicType}");
}
if (topic.Contains(MqttTopicTokens.ModelId))
{
return;
}
if (topic.Contains(nameToken))
{
namedTopicInterfaceIds.TryAdd(topic, new Dictionary<string, Dtmi>());
Dictionary<string, Dtmi> namedInterfaceIds = namedTopicInterfaceIds[topic];
foreach (string name in names)
{
if (!namedInterfaceIds.TryAdd(name, dtInterface.Id))
{
throw GetException(topic, dtInterface.Id, namedInterfaceIds[name], name);
}
}
}
else
{
if (!namelessTopicInterfaceIds.TryAdd(topic, dtInterface.Id))
{
throw GetException(topic, dtInterface.Id, namelessTopicInterfaceIds[topic]);
}
}
}
}