private List <string> ExtractCriteriaItems(string criteria, MovieInfo _info) { List <string> _criteriaItems = null; if (_info != null) { object _reflectedObject = _info; // try to get propertyinfo for the criteria Type _t = _info.GetType(); PropertyInfo _p = _t.GetProperty(criteria); // property not found on MovieInfo object if (_p == null) { // maybe it is a MediaInfoData property? _p = _t.GetProperty("MediaInfo"); if (_p != null) { // get MediaInfoData object from the MovieInfo MediaInfoData _mdata = _t.GetProperty("MediaInfo").GetValue(_reflectedObject, null) as MediaInfoData; if (_mdata != null) { // the object to get prop value is now MediaInfoData _reflectedObject = _mdata; // try to get Property for the criteria _p = _mdata.GetType().GetProperty(criteria); } } } if (_p != null) { if (_p.PropertyType == typeof(List <string>)) { // list of strings, split it and use individual item _criteriaItems = _p.GetValue(_reflectedObject, null) as List <string>; if (_criteriaItems != null) { _criteriaItems = (from c in _criteriaItems select c.Trim()).ToList <string>(); } } else { if (_p.PropertyType == typeof(string)) { string _value = _p.GetValue(_reflectedObject, null) as string; _value = _value != null?_value.Trim() : _value; if (criteria == "Name" || criteria == "OriginalTitle") // Name is always splitted by 1st char { _value = string.IsNullOrEmpty(_value) ? null : _value.Substring(0, 1).ToUpperInvariant(); } if (!string.IsNullOrEmpty(_value)) { // string, use it directly (if not Rating) if (criteria == "Rating") { // in this case try to convert to integer and use only integer part if (_info.dRating > 0) { _value = ((int)_info.dRating).ToString(); } else { _value = null; } } if (!string.IsNullOrEmpty(_value)) { _criteriaItems = new List <string>() { _value }; } } } } } } return(_criteriaItems); }