Skip to content

Use the package to get list of all class with own methods that you select with the attribute.

License

Notifications You must be signed in to change notification settings

sajadbz/ClassFinder

Repository files navigation

Class Finder

Use Bz.Helper.GetClassAndMethods<T>() method and custom your class or methods with [BzDescriptionAttribute] to get list of all class with own methods that you select with this attribute. My web site

Create static read-only object for get list of class and method that has [BzDescription("{your custom title}")] Attribute and use this object in your project

I use this to get all action in my controller for list of permission that want to check in user role permission.

Find it on : https://www.nuget.org/packages/Bz.ClassFinder/

Example :

Create an instance with class finder helper :

var location = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "","App.WebUI.dll");
IReadOnlyList<BzClassInfo> Permissions = Bz.ClassFinder.Helper.GetClassAndMethods(location).ToList();

How to use attribute:

using Bz.ClassFinder.Attributes;

namespace MyProjectNameSpace
{
    [BzDescription("Locations")]
    public class LocationsController : BaseAdminController
    {
        private readonly ILocationService _locationService;

        public LocationsController(ILocationService stateService)
        {
            _locationService = stateService;
        }

        [BzDescription("Location List")]
        public async Task<IActionResult> Index()
        {           
            return View(_locationService.GetAll(id));
        }

        [BzDescription("Create Location")]
        public async Task<IActionResult> Create(int? id)
        {
            return View();
        }       
    }
}

About

Use the package to get list of all class with own methods that you select with the attribute.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages