예제 #1
0
 public void SetState(IComponentState state, object obj)
 {
     foreach (var propertyInfo in GetStatePropertyInfo(obj))
     {
         if (!state.ContainsKey(propertyInfo.Name))
         {
             continue;
         }
         var propertyType = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType;
         propertyInfo.SetValue(this, Convert.ChangeType(state[propertyInfo.Name], propertyType), null);
     }
 }
예제 #2
0
 public void GetState(object obj, IComponentState state)
 {
     foreach (var propertyInfo in GetStatePropertyInfo(obj))
     {
         if (state.ContainsKey(propertyInfo.Name))
         {
             state[propertyInfo.Name] = propertyInfo.GetValue(obj);
         }
         else
         {
             state.Add(propertyInfo.Name, propertyInfo.GetValue(obj));
         }
     }
 }