MapMatchingProperties() публичный статический Метод

Maps the matching properties from one type to the other by name.

If the name does not match then it will not be mapped.

This class was intended to be used in a class that derives from "IValueInjection"

If there is no cast type then this will be thrown
public static MapMatchingProperties ( object target, object source ) : void
target object The target object.
source object The source object.
Результат void
Пример #1
0
        protected override void Inject(Slot source, object target)
        {
            MappingHelper.MapMatchingProperties(target, source);

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

            if (fileSize == null)
            {
                return;
            }
            if (nzbName == null)
            {
                return;
            }

            var fileSizeVal = MemorySizeConverter.ConvertToMb(source.size);

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


            fileSize.SetValue(target, fileSizeVal.ToString(CultureInfo.CurrentUICulture));
            nzbName.SetValue(target, source.nzb_name);
        }
Пример #2
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);
        }
Пример #3
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());
        }
Пример #4
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);
        }
Пример #5
0
 protected override void Inject(object source, ref T target)
 {
     MappingHelper.MapMatchingProperties(target, source);
 }