in src/DotPulsar/Schemas/AvroGenericRecordSchema.cs [192:223]
private object LoadGenericDatumReader()
=> Activator.CreateInstance(_avroReaderTypeInfo, avroSchema, avroSchema) ?? throw new SchemaException("Could not create GenericDatumReader");
private object LoadGenericDatumWriter()
=> Activator.CreateInstance(_avroWriterTypeInfo, avroSchema) ?? throw new SchemaException("Could not create GenericDatumWriter");
private static MethodInfo LoadGenericDatumReaderMethod(IEnumerable<MethodInfo> methods)
{
const string name = "Read";
const string secondParamFullname = "Avro.IO.Decoder";
foreach (var method in methods)
{
if (method.Name != name || method.ReturnType != typeof(T))
continue;
var parameters = method.GetParameters();
if (parameters.Length != 2)
continue;
var param1Fullname = parameters[1].ParameterType.FullName;
if (param1Fullname is null)
continue;
if (parameters[0].ParameterType != typeof(T) || !param1Fullname.Equals(secondParamFullname))
continue;
return method;
}
throw new SchemaException($"A method with the name '{name}' matching the delegate was not found");
}