What modern (PCL) equivalent for Handshake.XOnXOff

2019-09-01 07:48发布

I was using this legacy code:

SerialPort serialPort = new SerialPort();
serialPort.BaudRate = 19200;
serialPort.Handshake = Handshake.XOnXOff;

...but trying to port it to VS 2013 / .NET 4.5.1 in the "Core" (Portable Class Library) portion of a Xamarin solution, I get, "The name 'Handshake' does not exist in the current context"

According to this, the Handshake enum is in System.IO.Ports namespace, but adding that to my usings evokes "The type or namespace name 'Ports' does not exist in the namespace 'System.IO' (are you missing an assembly reference?)"

Perhaps I am missing an assembly reference? The link above says it's in System. My only reference is ".NET Portable Subset" which I assume (I know, I know, when you ASSume you Aynchronously Syncopate Sinkholes or something like that) would have System embedded in it.

When I r-click References and select Add Reference..., the options proffered are somewhat slight:

enter image description here

So...how can I use Handshake.XOnXOff? If I can't, what are my viable options?

1条回答
冷血范
2楼-- · 2019-09-01 08:02

I don't think you're going to be able to implement print functionality in a platform agnostic way. Your best bet would be to define some sort of IPrinting interface. That interface can be implemented in a platform specific library, then a reference can be passes into your PCL, so that the PCL can hand off the printing duties via the Interface.

查看更多
登录 后发表回答