/// <summary> /// This method will set the Property value in API model's property by reading the value from action /// </summary> /// <param name="aPIModel"></param> /// <param name="propName"></param> /// <param name="act"></param> private void SetPropertyValue(ApplicationAPIModel aPIModel, string propName, string modelPropertyName, Act act) { if (aPIModel != null && act != null) { try { PropertyInfo actProp = act.GetType().GetProperty(nameof(Act.ActInputValues)); if (actProp != null) { ObservableList <ActInputValue> inputValues = (ObservableList <ActInputValue>)actProp.GetValue(act); if (inputValues != null) { var val = inputValues.Where(x => x.FileName == propName).Select(x => x.Value).FirstOrDefault(); if (val != null) { PropertyInfo apiProp = aPIModel.GetType().GetProperty(modelPropertyName); var modelVal = apiProp.GetValue(aPIModel); if (apiProp.PropertyType.IsEnum) { apiProp.SetValue(aPIModel, Enum.Parse(apiProp.PropertyType, Convert.ToString(val))); } else if (apiProp.PropertyType.Equals(typeof(Boolean))) { apiProp.SetValue(aPIModel, Convert.ToBoolean(val)); } else { if (modelVal == null || string.IsNullOrEmpty(Convert.ToString(modelVal))) { apiProp.SetValue(aPIModel, val); } } } } } } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Error occurred while Setting property value", ex); } } }