WebApiContrib / WebApiContrib.Formatting.ProtoBuf

Web API formatter based on ProtoBuf
http://nuget.org/packages/WebApiContrib.Formatting.ProtoBuf
MIT License
30 stars 19 forks source link

There is a bug for deserializing List<T>or IEnumerable<T> when using httpResponse.Content.ReadAsAsync<List<T> function #8

Open zfkingth opened 8 years ago

zfkingth commented 8 years ago

should CanReadTypeCore function change as follow:

    private static bool CanReadTypeCore(Type type)
    {
        bool isCan = type.GetCustomAttributes(typeof(ProtoContractAttribute)).Any();

        if (!isCan && typeof(IEnumerable).IsAssignableFrom(type))
        {
            var temp = type.GetGenericArguments().FirstOrDefault();
            isCan = temp.GetCustomAttributes(typeof(ProtoContractAttribute)).Any();
        }

        return isCan;
    }