c # templated generation interfaces

Recent intend to do such a thing, a desktop system integration project can either be deployed as a software deployment process, you can put business service deployment.

That generally means that we have to write two complete sets of things, a set of UI is a direct call service, is set Ui call RPC. This is more and more operations.

Now intends to service interfaces of, UI interface to directly call the factory returns, underlayer autofac control.

Another set of direct template generation, template interfaces that will be called generation.

Depending on the configuration, respectively, call the business class or template generated classes.

Here briefly template generation class.

All interface calls packaged into a packaging structure, which contains the name of the method call, the name of the interface, and the parameters in the form KV.

Such configuration again packed incoming client request class, the request class in accordance with the actual needs of the processing structure, so there is no need to prepare two sets. And open quickly.

You have to do is modify the client request class.

Template generation using emit generation. Of course, you can dynamically compile. He began to use codedom, behind only know that Microsoft gave up.

Here not posted code, the code on the top Git. Method for each interface method is called internally project RequestProxy in SrvImplFactory class.

This is just a demo, template support methods, properties, events. SrvImplFactory are examples only need to modify their own sound.

Address: https://github.com/jinyuttt/IFProvider.git

Guess you like

Origin www.cnblogs.com/jinyu20180311/p/11228009.html