示例#1
0
 //Loop through all the properties
 public static void AddValuesToMovementsViewModel(object movement, ref MovementsViewModel movementsViewModel)
 {
     foreach (var property in movementsViewModel.GetType().GetProperties())
     {
         var propertyValue = GetPropertyValue(movement, property.Name);
         if (propertyValue != null)
         {
             var properties = GetPropertiesNamesFromObject(movementsViewModel);
             if (properties.Contains(property.Name))
             {
                 movementsViewModel.GetType().GetProperty(property.Name)?.SetValue(movementsViewModel, propertyValue);
             }
         }
     }
 }
示例#2
0
 //Loop through all the properties
 private static void AddValueToMovementsModel(object movement, ref MovementsViewModel movementsViewModel)
 {
     foreach (var property in movementsViewModel.GetType().GetProperties())
     {
         var propertyValue = GetPropertyValue(movement, property.Name);
         if (propertyValue != null)
         {
             SetPropertyValueToMovementsViewModel(property.Name, propertyValue, ref movementsViewModel);
         }
     }
 }
示例#3
0
 public static bool SetPropertyValueToMovementsViewModel(string propertyName, object propertyValue, ref MovementsViewModel modelToUpdate)
 {
     try
     {
         var properties = GetPropertiesNamesFromObject(modelToUpdate);
         if (properties.Contains(propertyName))
         {
             modelToUpdate.GetType().GetProperty(propertyName).SetValue(modelToUpdate, propertyValue);
             return(true);
         }
         return(false);
     }
     catch
     {
         return(false);
     }
 }