in codegen/src/Azure.Iot.Operations.ProtocolCompiler/SchemaGenerator/SchemaTransformFactory.cs [14:49]
public static IEnumerable<ITemplateTransform> GetTelemetrySchemaTransforms(string payloadFormat, string projectName, CodeName genNamespace, Dtmi interfaceId, ITypeName schema, List<(string, string, DTSchemaInfo, bool, int)> nameDescSchemaRequiredIndices, CodeName? sharedPrefix, bool isSeparate)
{
switch (payloadFormat)
{
case PayloadFormat.Raw:
case PayloadFormat.Custom:
if (nameDescSchemaRequiredIndices.Any(ndsri => ndsri.Item3.GetType() != typeof(DTBytesInfo)))
{
throw new Exception($"PayloadFormat '{payloadFormat}' does not support any Telemetry schema other than 'bytes'");
}
if (!isSeparate && nameDescSchemaRequiredIndices.Count > 1)
{
throw new Exception($"PayloadFormat '{payloadFormat}' requires multiple Telemetries to have distinct topics by name");
}
yield break;
case PayloadFormat.Avro:
yield return new TelemetryAvroSchema(projectName, genNamespace, schema, nameDescSchemaRequiredIndices, sharedPrefix);
yield break;
case PayloadFormat.Cbor:
yield return new TelemetryJsonSchema(genNamespace, GetSchemaId(interfaceId, schema), schema, nameDescSchemaRequiredIndices, sharedPrefix, setIndex: true);
yield break;
case PayloadFormat.Json:
yield return new TelemetryJsonSchema(genNamespace, GetSchemaId(interfaceId, schema), schema, nameDescSchemaRequiredIndices, sharedPrefix, setIndex: false);
yield break;
case PayloadFormat.Proto2:
yield return new TelemetryProto2(projectName, genNamespace, schema, nameDescSchemaRequiredIndices);
yield break;
case PayloadFormat.Proto3:
yield return new TelemetryProto3(projectName, genNamespace, schema, nameDescSchemaRequiredIndices);
yield break;
default:
throw GetFormatNotRecognizedException(payloadFormat);
}
}