Пример #1
0
        /// <summary>
        /// The actual task.
        /// </summary>
        private async Task <TVDBSeries> GetFilterSeries()
        {
            string query = "/filter?keys=";

            foreach (var property in IncludedProperties)
            {
                query += property;
                if (property != IncludedProperties.Last())
                {
                    query += ",";
                }
            }
            var request = ApiConfiguration.BaseUrl + $"/series/{SeriesID}";

            if (IncludedProperties.Any())
            {
                request += query;
            }
            var response = await GetAsync(request);

            var result = await response.Content.ReadAsStringAsync();

            var series = JsonConvert.DeserializeObject <TVDBSeriesResponse>(result).Data;

            series.ID = SeriesID;
            return(series);
        }
Пример #2
0
        /// <summary>
        /// Needs to be called before beginning await or task, sets properties to be available.
        /// </summary>
        /// <param name="property">Property of Series Object</param
        public SeriesFilterRequest IncludeProperty(Expression <Func <TVDBSeries, object> > property)
        {
            Type type = typeof(SeriesFilterRequest);

            var member = property.Body as MemberExpression;

            if (member == null)
            {
                throw new ArgumentException(string.Format(
                                                "Expression '{0}' refers to a method, not a property.",
                                                property.ToString()));
            }

            PropertyInfo propInfo = member.Member as PropertyInfo;

            if (propInfo == null)
            {
                throw new ArgumentException(string.Format(
                                                "Expression '{0}' refers to a field, not a property.",
                                                property.ToString()));
            }

            IncludedProperties.Add(propInfo.Name);
            return(this);
        }