/// <summary> /// Used in property name mapping to specify a property type converter for the attribute. /// </summary> /// <param name="converter"></param> public AvroFieldAttribute(Type converter) { FieldName = null; if (converter != null) { Converter = (IAvroFieldConverter)Activator.CreateInstance(converter); } }
public DotnetProperty(PropertyInfo property, Avro.Schema.Type schemaTag, IAvroFieldConverter converter, ClassCache cache) { _property = property; Converter = converter; if (!IsPropertyCompatible(schemaTag)) { if (Converter == null) { var c = cache.GetDefaultConverter(schemaTag, _property.PropertyType); if (c != null) { Converter = c; return; } } throw new AvroException($"Property {property.Name} in object {property.DeclaringType} isn't compatible with Avro schema type {schemaTag}"); } }
/// <summary> /// Add a default field converter /// </summary> /// <param name="converter"></param> public static void AddDefaultConverter(IAvroFieldConverter converter) { _defaultConverters.Add(converter); }