mardi 8 août 2017

How to call multiple optional functions one line

Assume that I have multiple functions in my simple server framework like this below It can takes multiple functions like this :

new TestServer()
    .DOBind("ip", "port")
    .SetMaxBindTries(3)
    .SetMaxConnections(300)
    .ONBind(delegate {...})
    .ONReceiveBytes(delegate {...})
    .ONSocketStatusChanged(delegate {...})
    .ONBlaBlaBla...

  • How can I do something like this ?
  • What are the "special key words" to investigate ?
  • What kind of "class-design / design-pattern" structure should I follow ?

Aucun commentaire:

Enregistrer un commentaire