How to tell if there is a console

前端 未结 10 2227
庸人自扰
庸人自扰 2020-12-14 16:34

I\'ve some library code that is used by both console and WPF apps. In the library code, there are some Console.Read() calls. I only want to do those input rea

10条回答
  •  长情又很酷
    2020-12-14 17:11

    If you want a good design, abstract the GUI dependences using an interface.

    Implement a concrete class for the console version, another for the WPF version, and inject the correct version using any way (dependency injection, inversion of control, etc).

提交回复
热议问题