using Common.Pagination;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Common.Extensions;

public static class StringExtensions
{
    public static IDictionary<string, object?> AsDictionary(this object source, 
        BindingFlags bindingAttr = BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance)
    {
        return source.GetType().GetProperties(bindingAttr).ToDictionary
        (
            propInfo => propInfo.Name,
            propInfo => propInfo.GetValue(source, null)
        );
    }
}
