CallfireApiClient.CallfireContractResolver.IsEmptyCollection C# (CSharp) Method

IsEmptyCollection() private method

private IsEmptyCollection ( JsonProperty property, object target ) : bool
property Newtonsoft.Json.Serialization.JsonProperty
target object
return bool
        private bool IsEmptyCollection(JsonProperty property, object target)
        {
            var value = property.ValueProvider.GetValue(target);
            var collection = value as ICollection;
            if (collection != null && collection.Count == 0)
            {
                return true;
            }
            if (!typeof(IEnumerable).IsAssignableFrom(property.PropertyType))
            {
                return false;
            }
            var countProp = property.PropertyType.GetProperty("Count");
            if (countProp == null)
            {
                return false;
            }

            var count = (int)countProp.GetValue(value, null);
            return count == 0;
        }