示例#1
0
 private void TrySetValue(object objectInstance, PropertyInfo propertyInfo, PropertyData propertyData)
 {
     try
     {
         propertyInfo.SetValue(objectInstance, propertyData?.Value);
     }
     catch (Exception)
     {
         try
         {
             if (propertyInfo != null)
             {
                 if (propertyInfo.ReflectedType != null && propertyData?.Type != null)
                 {
                     LogEventHandler.Warning($"{objectInstance.GetType().FullName}.{propertyData.Name} : should be type of {propertyData.Type}. Failed with value: {propertyData.Value}");
                 }
                 propertyInfo.SetValue(objectInstance, propertyData?.Value?.ToString());
             }
         }
         catch (Exception exception)
         {
             var wmiException = new WMIGeneralException(EndPoint, exception);
             LogEventHandler.Exception(wmiException);
         }
     }
 }