public void Bind(object target, PropertyInfo propertyInfo, object value) { var type = propertyInfo.PropertyType; var obj = Activator.CreateInstance(type); var propertyBinder = new PropertyBinder(); propertyBinder.Bind(obj, x => x.Cells["Id"].Value.Equals(value.ToString())); propertyInfo.SetValue(target, obj, null); }
public void Bind(object target, PropertyInfo propertyInfo, object value) { var type = propertyInfo.PropertyType; var obj = Activator.CreateInstance(type); var propertyBinder = new PropertyBinder(); propertyBinder.Bind(obj, x => x.Cells["Id"].Value.Equals(value.ToString())); propertyInfo.SetValue(target, obj, null); }
public void Bind(object target, PropertyInfo propertyInfo, object value) { var type = propertyInfo.PropertyType; var genericType = type.GetGenericArguments()[0]; var valueString = value.ToString(); var data = new List<string>(); if (valueString.Contains(",")) { Array.ForEach(valueString.Split(','), data.Add); } var listObj = (IList)Activator.CreateInstance(type); foreach (var item in data) { var obj = Activator.CreateInstance(genericType); var propertyBinder = new PropertyBinder(); var tempValue = item; propertyBinder.Bind(obj, x => x.Cells["Id"].Value.Equals(tempValue)); listObj.Add(obj); } propertyInfo.SetValue(target, listObj, null); }
public void Bind(object target, PropertyInfo propertyInfo, object value) { var type = propertyInfo.PropertyType; var genericType = type.GetGenericArguments()[0]; var valueString = value.ToString(); var data = new List <string>(); if (valueString.Contains(",")) { Array.ForEach(valueString.Split(','), data.Add); } var listObj = (IList)Activator.CreateInstance(type); foreach (var item in data) { var obj = Activator.CreateInstance(genericType); var propertyBinder = new PropertyBinder(); var tempValue = item; propertyBinder.Bind(obj, x => x.Cells["Id"].Value.Equals(tempValue)); listObj.Add(obj); } propertyInfo.SetValue(target, listObj, null); }