What is a context?

后端 未结 4 1864
攒了一身酷
攒了一身酷 2021-01-31 02:55

It seems to me that a Context class is a control console whose object can invoke any included functions, such as Datacontext and DomainContext in WCF Ria service. Do I understan

4条回答
  •  Happy的楠姐
    2021-01-31 03:24

    A context is commonly a storage mechanism for a group of actions. HttpContext, for example

    Encapsulates all HTTP-specific information about an individual HTTP request.

    For your WCF example, the "context" is the service. Different services have different contexts. Contexts can be as granular as you want. Some are broad, like the DomainContext, and some are granular, like HttpContext.

    Contexts are everywhere, make them when you need to access or set like minded data or functions to things that can be decoupled.

    All contexts are like this, they just encapsulate logic for particular action sets.

    Here is another post describing the context design pattern.

提交回复
热议问题