File tree Expand file tree Collapse file tree
src/extensions/BootstrapBlazor.OpcDa Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ namespace BootstrapBlazor.OpcDa;
1313/// OPC Server 操作类
1414/// </summary>
1515[ SupportedOSPlatform ( "windows" ) ]
16- class OpcServer : IOpcServer
16+ sealed class OpcServer : IOpcServer
1717{
1818 private Opc . Da . Server ? _server = null ;
1919 private readonly ConcurrentDictionary < string , HashSet < OpcReadItem > > _valuesCache = [ ] ;
@@ -54,7 +54,7 @@ public void Disconnect()
5454 {
5555 ServerName = string . Empty ;
5656
57- if ( _server != null && _server . IsConnected )
57+ if ( _server is { IsConnected : true } )
5858 {
5959 foreach ( Subscription sub in _server . Subscriptions )
6060 {
@@ -127,7 +127,7 @@ public HashSet<OpcWriteItem> Write(params HashSet<OpcWriteItem> items)
127127
128128 private Opc . Da . Server GetOpcServer ( )
129129 {
130- if ( _server == null )
130+ if ( _server is not { IsConnected : true } )
131131 {
132132 throw new InvalidOperationException ( "OPC Server is not connected." ) ;
133133 }
@@ -138,7 +138,7 @@ private Opc.Da.Server GetOpcServer()
138138 /// Dispose 方法
139139 /// </summary>
140140 /// <param name="disposing"></param>
141- protected virtual void Dispose ( bool disposing )
141+ private void Dispose ( bool disposing )
142142 {
143143 if ( disposing )
144144 {
You can’t perform that action at this time.
0 commit comments