Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 public PropertyDescriptorsInfo(Type type, PropertyDescriptorKind kind)
 {
     this.Type = type;
     this.Kind = kind;
 }