I have a class called Foo, as shown in the example below. The Content property of this class is a generic list type. I want to check if the Content property has one or more items. But I am getting an error as "an attribute argument cannot use type parameters". I'm waiting for your help on this. Thanks in advance..
[DataContract]
public class Foo<T> where T : class
{
[JsonConverter(typeof(SingleOrMany<T>))]
public List<T> Content { get; set; }
}
public class SingleOrMany<T> : JsonConverter
{
public override bool CanConvert(System.Type objectType)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
My question is different from the example below. Here T is used in a generic list.
[JsonConverter(typeof(ConcreteTypeConverter<List<T>>))]