public bool IsEmpty(object value) { if (value == null) return true; var list = value as IList; if (list == null) throw new InvalidOperationException("Not an IList"); return list.Count == 0; }