Home > Net >  C # interface USES
C # interface USES

Time:09-22

Public interface IPostResponser
{
Void PostProcess (NetMessageResponse message);
}

The class NetSession: INetSession
{
Public IPostResponser PostResponser {get; The set; }
.
Public void Disconnected ()
{
This. PostResponser =null;
}
Public byte [] the method GetResponse ()
{
If ( PostResponser !=null)
This. PostResponser . PostProcess (Response).
.
}
}

Excuse me,
1. Usage of this kind of interface name?
2. This. Whether PostResponser when NetSession structure is not empty?
Thank you,

CodePudding user response:

1, said PostResponser is to implement the interface of type
2, how to look at the constructor of NetSession wrote, if you have set up the object code, would not be a null

CodePudding user response:

The equivalent of 1
 
Public class C_PostResponser: IPostResponser
{}

The class NetSession: INetSession
{
Public C_PostResponser PostResponser {get; The set; }
.

CodePudding user response:

1. This kind of the usage of the interface name?
Maybe you can call it a processor injection mode, if set PostResponser, then use it to handle the response data,

2. This. Whether PostResponser when NetSession structure is not empty?
NetSession structure, null , after construction, can be set,
  •  Tags:  
  • C#
  • Related