There is a site on ASP.NET MVC 5.

I thought about the implementation of various "modules" for it, for example, there is a registration on the site, after sending the form in the controller, a number of checks are performed, let's say you need to add Email validation to the content in the list of prohibited or validating the user name for the presence of obscene words.

It is clear what can be done inside the usual methods for these checks, but whether it is possible to make a module so that in the controller in the registration method the methods of all classes are executed in the right places through reflection included in the namespace , for example MySite.Modules.xxx , where xxx - method?

To write a module there will be a condition: implement the IMyModule custom interface, which will contain the validation method

That's how I see it in my head, I would like to know the opinion of whether to do this correctly and whether it is possible to perform the methods of the classes included in a particular namespace through reflection

Maybe I reinvent the wheel and it is somehow easier ... but I don’t know

  • You need LoadAssembly, from it (Assembly) take the module with index zero. And there already GetMethod and Invoke - nick_n_a
  • one
    Most likely you need some IoC container. For example, MEF. - Vlad
  • See the implementation of DBMS drivers, for example, Firebird sourceforge.net/p/firebird/NETProvider/ci/… They are implemented via the entry point Factory - nick_n_a

0