Open-source component, clover. Proxy. please correct me

Source: Internet
Author: User

Clover. Proxy is a Class Library Based on. NET 4.0,

Project address: https://github.com/xwj90/Clover.Proxy (MIT, whatever you want)

It provides a simple way to execute the methods and attributes in the existing class library by proxy. It can be used in the following situations:
 

1. Add beforecall and aftercall to the methods and attributes of the existing class.

    • By assigning delegate values, you can easily customize beforecall and aftercall.
    • In beforecall and aftercall, you can perform log recording, analyze parameters, modify parameters, and record the number of calls to each method. (You can enable or disable the function through configuration to facilitate debugging)
    • Through configuration, you can easily control the impact scope.
    • Automatically Generated by modifyingCode, You can do more, such as automatically adding logs to some methods and modifying variables during execution.

2. the proxy supports migrating existing methods to different AppDomains for execution (the main function is completed)

    • Control the performance and resource consumption of independent appdomain
    • Cross-appdomain operations are highly independent and can be extended to automatic update and restart (in Plug-in form that requires development)
    • Because each appdomain supports its own configuration file, we can modify the behavior of many existing class libraries by configuring different configuration files for different classes and assemblies.
      • For example, if a log system is used for an existing project, the logs of the entire project must be written to a file. Different configuration files allow different classes or differentProgramSet to write different log files
    • Cross-origin performance loss

3. This project is more like a research project that involves the following technologies: (if you are interested, look at the source code)

    • Dynamic generation of CS files and compilation into assembly
    • Analyze type-related information
    • Knowledge about class inheritance
    • Dynamically create appdomain and load assembly
    • Cross-origin operations

 

The following is a sample:

Proxyservice service = New Proxyservice ();
Service. beforecall = (p) =>
{
Console. writeline ( " Before call: " + P. Arguments );
};
Service. aftercall = (p) =>
{
Console. writeline ( " After call: " + P. returnvalue );
};

VaR Item = service. Create <testwrapper> ();

// Method
VaR R1 = item. getall ( 128 , " Test string " );
Console. writeline ();

// Property can be set by configuring a method, or some methods need to call beforecall & aftercall
VaR R2 = item. Name;
Console. writeline ();



VaR Item2 = service. Create <testwrapper2> ();
VaR R3 = item2.test ( " Test string " );// Run method in remote domain // Incomplete

Thanks to shiweichuan and weikaishio

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.