Example #1
0
        protected override void Inject(LogResult source, object target)
        {
            MappingHelper.MapMatchingProperties(target, source);

            var dateTime = target.GetType().GetProperty("Time", BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

            if (dateTime == null)
            {
                return;
            }

            var convertedTime = source.Time.UnixTimeStampToDateTime();

            if (convertedTime == default(DateTime))
            {
                return;
            }

            dateTime.SetValue(target, convertedTime);
        }
Example #2
0
        protected override void Inject(NzbGetHistoryResult source, object target)
        {
            MappingHelper.MapMatchingProperties(target, source);

            var fileSize = target.GetType().GetProperty("FileSize", BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

            if (fileSize == null)
            {
                return;
            }

            var fileSizeVal = source.FileSizeMB;

            if (fileSizeVal == default(int))
            {
                return;
            }

            fileSize.SetValue(target, fileSizeVal.ToString());
        }
Example #3
0
        protected override void Inject(SonarrEpisode source, object target)
        {
            MappingHelper.MapMatchingProperties(target, source);

            var airDate = target.GetType().GetProperty("AirDate", BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

            if (airDate == null)
            {
                return;
            }

            var airDateUtc = target.GetType().GetProperty("AirDateUtc", BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);

            if (airDateUtc == null)
            {
                return;
            }

            DateTime convertedAirDate;

            DateTime.TryParse(source.airDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out convertedAirDate);
            if (convertedAirDate == default(DateTime))
            {
                return;
            }

            DateTime convertedAirDateUtc;

            DateTime.TryParse(source.airDateUtc, CultureInfo.InvariantCulture, DateTimeStyles.None, out convertedAirDateUtc);
            if (convertedAirDateUtc == default(DateTime))
            {
                return;
            }

            airDate.SetValue(target, convertedAirDate);
            airDateUtc.SetValue(target, convertedAirDateUtc);
        }
 protected override void Inject(object source, ref T target)
 {
     MappingHelper.MapMatchingProperties(target, source);
 }