Serialize property

Hi all,

I want to create an attribute that would apply a specific serializer when the object is instatiated. So i’ve created the following:

[AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
public class PiiInformationAttribute : BsonSerializerAttribute
{
	public PiiInformationAttribute() : base(typeof(PiiInformationSerializer)) { }

	private class PiiInformationSerializer : SerializerBase<string>
	{
		public override void Serialize(BsonSerializationContext ctx, BsonSerializationArgs args, string value)
		{
			// Serialize logic
		}

		public override string Deserialize(BsonDeserializationContext ctx, BsonDeserializationArgs args)
		{
			//Deserialize logic
		}
	}
}

With the code above i’m able to decorate a DBO like this, for example:

public class Person
{
	public Person()
	{
		
	}

	[PiiInformation]
	public string Name { get; set; }

	[PiiInformation]
	public string Email { get; set; }

	[PiiInformation]
	public string Telephone { get; set; }

	[PiiInformation]
	public string Mobile { get; set; }

	public IEnumerable<string> AddressLines { get; set; }
}

But i want also to make addressLines be decorated but because it is a list of string mongo gives an error that is unable to deserialize. Is there a way to make the attribute defined above valid to primitive type and also list’s of the same primitive type?

Regards