In.. net, the context concept runs through. net. it provides services and content similar to the running environment. in. in. net, context-based interception technology has been very obscure, and there are not many documents to explain. However, context-based interception technology provides very powerful functions. So that we can easily implement a programming mode similar to AOP .. Net3.0 uses context interception technology in most cases.
In. in. net, the common particles of component services are domain and context ). among them, the services provided in the domain are generally only 'synchronous region '. of course ,. net also provides many COM + services, but the components (classes) that need to be served directly or indirectly inherit from servicedcomponent (components to be served ).. all the COM + services provided in. NET are in the namespace system. in enterpriseservices, such as message queue, instant activation, Object pool... and other services.
In use. NET development, we all know that we use any one. the code written in the language supported by. NET is managed code. the so-called managed code generation il language can only run in CLR. also, you can use the zookeeper reclaim function provided by CLR to host the heap... and so on. however, when Windows provides a process for our il operation, it does not know the so-called managed environment. Windows only provides processes, and there is no concept of a managed environment in the process. the domain serves as a bridge between Windows processes and Il. In a Windows process, all domains share the services provided by CLR, such as garbage collection, managed heap, and JIT, loading and detaching an assembly. That is to say, all our il code must run in the domain. Of course, when we start. net Program, a default domain will be created to load and run our. and provides a managed heap. You can also create a new domain. Therefore, each Windows process can host multiple domains. In. net, objects cannot be directly referenced across domains. Each. Net object is created as a hosted heap of the domain to which it belongs. The cross-origin access of an object must use a proxy, and the object can be blocked (directly or indirectly inherited from financialbyrefobject). The cross-origin access object is called remote access ).
In. net, the domain granularity is still very large. If we do not explicitly create a new domain, all the components (classes) in our program usually run in the same domain. In. net, context provides a runtime environment with a smaller granularity than the domain. A domain can have multiple contexts, but one context can belong to only one domain.
Like the domain, our. the. NET Component (class) must also run in different contexts, but different contexts provide different context services. Each domain also has a default context, the default context does not provide any services. The biggest advantage of context is that we can use context interception technology to provide custom services for the components (classes) hosted in the context. In this way, we can implement the so-called AOP programming. We can add the so-called pipeline work in AOP as a service to the fixed service below, so that every call to the component (class) in this context will be intercepted, then add the Service (pipeline method) to the group component (class), as if to weave the Service (pipeline method) into the (AOP term) to the component (class.
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.