private static void Trim(this object source, PropertyDescriptorKind kind, PropertyDescriptor[] properties, char[] trimChars) { if (source == null) { return; } if (source is DataTable dataTable) { dataTable.TrimDataTable(trimChars); return; } string value; foreach (PropertyDescriptor property in properties) { value = (string)property.GetValue(source); if (!string.IsNullOrEmpty(value)) { property.SetValue(source, value.Trim(trimChars)); } } if (kind == PropertyDescriptorKind.Class) { if (source is IEnumerable items) { items.TrimEnumerable(trimChars); } } }
public PropertyDescriptorsInfo(Type type, PropertyDescriptorKind kind) { this.Type = type; this.Kind = kind; }