markus / ConvertService / ServiceController / Markus.Service.StationController / Extensions / ConvertItemChangeValue.cs @ 5c387707
이력 | 보기 | 이력해설 | 다운로드 (944 Bytes)
1 |
using Markus.Service.WcfClient.StationServiceTask; |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.Linq; |
5 |
using System.Text; |
6 |
using System.Threading.Tasks; |
7 |
|
8 |
namespace Markus.Service.StationController.Extensions |
9 |
{ |
10 |
public static class ConvertItemEx |
11 |
{ |
12 |
public static void ChangeValues(object changeitem, object newitem) |
13 |
{ |
14 |
var changeProp = changeitem.GetType().GetProperties(); |
15 |
var newProp = newitem.GetType().GetProperties(); |
16 |
|
17 |
foreach (var item in changeProp) |
18 |
{ |
19 |
|
20 |
var newinfo = newProp.Where(x => x.Name == item.Name); |
21 |
|
22 |
if(newinfo.Count() > 0) |
23 |
{ |
24 |
if (item.GetValue(changeitem) != newinfo.First().GetValue(newitem)) |
25 |
{ |
26 |
item.SetValue(changeitem, newinfo.First().GetValue(newitem)); |
27 |
} |
28 |
} |
29 |
} |
30 |
} |
31 |
|
32 |
} |
33 |
} |