@@ -74,7 +74,8 @@ public ClientSamples(
7474 {
7575 m_telemetry = telemetry ;
7676 m_logger = telemetry . CreateLogger < ClientSamples > ( ) ;
77- m_validateResponse = validateResponse ?? ClientBase . ValidateResponse ;
77+ m_validate = validateResponse ;
78+
7879 m_quitEvent = quitEvent ;
7980 m_verbose = verbose ;
8081 m_desiredEventFields = [ ] ;
@@ -146,7 +147,7 @@ public async Task ReadNodesAsync(ISession session, CancellationToken ct = defaul
146147 DiagnosticInfoCollection diagnosticInfos = response . DiagnosticInfos ;
147148
148149 // Validate the results
149- m_validateResponse ( resultsValues , nodesToRead ) ;
150+ ValidateResponse ( resultsValues , nodesToRead ) ;
150151
151152 // Display the results.
152153 foreach ( DataValue result in resultsValues )
@@ -187,7 +188,7 @@ public async Task WriteNodesAsync(ISession session, CancellationToken ct = defau
187188 // Int32 Node - Objects\CTT\Scalar\Scalar_Static\Int32
188189 var intWriteVal = new WriteValue
189190 {
190- NodeId = new NodeId ( "ns=2;s=Scalar_Static_Int32" ) ,
191+ NodeId = NodeId . Parse ( "ns=2;s=Scalar_Static_Int32" ) ,
191192 AttributeId = Attributes . Value ,
192193 Value = new DataValue { Value = 100 }
193194 } ;
@@ -196,7 +197,7 @@ public async Task WriteNodesAsync(ISession session, CancellationToken ct = defau
196197 // Float Node - Objects\CTT\Scalar\Scalar_Static\Float
197198 var floatWriteVal = new WriteValue
198199 {
199- NodeId = new NodeId ( "ns=2;s=Scalar_Static_Float" ) ,
200+ NodeId = NodeId . Parse ( "ns=2;s=Scalar_Static_Float" ) ,
200201 AttributeId = Attributes . Value ,
201202 Value = new DataValue { Value = ( float ) 100.5 }
202203 } ;
@@ -205,7 +206,7 @@ public async Task WriteNodesAsync(ISession session, CancellationToken ct = defau
205206 // String Node - Objects\CTT\Scalar\Scalar_Static\String
206207 var stringWriteVal = new WriteValue
207208 {
208- NodeId = new NodeId ( "ns=2;s=Scalar_Static_String" ) ,
209+ NodeId = NodeId . Parse ( "ns=2;s=Scalar_Static_String" ) ,
209210 AttributeId = Attributes . Value ,
210211 Value = new DataValue { Value = "String Test" }
211212 } ;
@@ -224,7 +225,7 @@ public async Task WriteNodesAsync(ISession session, CancellationToken ct = defau
224225 DiagnosticInfoCollection diagnosticInfos = response . DiagnosticInfos ;
225226
226227 // Validate the response
227- m_validateResponse ( results , nodesToWrite ) ;
228+ ValidateResponse ( results , nodesToWrite ) ;
228229
229230 // Display the results.
230231 Console . WriteLine ( "Write Results :" ) ;
@@ -302,8 +303,8 @@ public async Task CallMethodAsync(ISession session, CancellationToken ct = defau
302303 // Define the UA Method to call
303304 // Parent node - Objects\CTT\Methods
304305 // Method node - Objects\CTT\Methods\Add
305- var objectId = new NodeId ( "ns=2;s=Methods" ) ;
306- var methodId = new NodeId ( "ns=2;s=Methods_Add" ) ;
306+ var objectId = NodeId . Parse ( "ns=2;s=Methods" ) ;
307+ var methodId = NodeId . Parse ( "ns=2;s=Methods_Add" ) ;
307308
308309 // Define the method parameters
309310 // Input argument requires a Float and an UInt32 value
@@ -351,8 +352,8 @@ public async Task EnableEventsAsync(
351352 // Define the UA Method to call
352353 // Parent node - Objects\CTT\Alarms
353354 // Method node - Objects\CTT\Alarms\Start
354- var objectId = new NodeId ( "ns=7;s=Alarms" ) ;
355- var methodId = new NodeId ( "ns=7;s=Alarms.Start" ) ;
355+ var objectId = NodeId . Parse ( "ns=7;s=Alarms" ) ;
356+ var methodId = NodeId . Parse ( "ns=7;s=Alarms.Start" ) ;
356357
357358 // Define the method parameters
358359 // Input argument requires a Float and an UInt32 value
@@ -457,7 +458,7 @@ public async Task<bool> SubscribeToDataChangesAsync(
457458 var intMonitoredItem = new MonitoredItem ( subscription . DefaultItem )
458459 {
459460 // Int32 Node - Objects\CTT\Scalar\Simulation\Int32
460- StartNodeId = new NodeId ( "ns=2;s=Scalar_Simulation_Int32" ) ,
461+ StartNodeId = NodeId . Parse ( "ns=2;s=Scalar_Simulation_Int32" ) ,
461462 AttributeId = Attributes . Value ,
462463 DisplayName = "Int32 Variable" ,
463464 SamplingInterval = itemSamplingInterval ,
@@ -471,7 +472,7 @@ public async Task<bool> SubscribeToDataChangesAsync(
471472 var floatMonitoredItem = new MonitoredItem ( subscription . DefaultItem )
472473 {
473474 // Float Node - Objects\CTT\Scalar\Simulation\Float
474- StartNodeId = new NodeId ( "ns=2;s=Scalar_Simulation_Float" ) ,
475+ StartNodeId = NodeId . Parse ( "ns=2;s=Scalar_Simulation_Float" ) ,
475476 AttributeId = Attributes . Value ,
476477 DisplayName = "Float Variable" ,
477478 SamplingInterval = itemSamplingInterval ,
@@ -484,7 +485,7 @@ public async Task<bool> SubscribeToDataChangesAsync(
484485 var stringMonitoredItem = new MonitoredItem ( subscription . DefaultItem )
485486 {
486487 // String Node - Objects\CTT\Scalar\Simulation\String
487- StartNodeId = new NodeId ( "ns=2;s=Scalar_Simulation_String" ) ,
488+ StartNodeId = NodeId . Parse ( "ns=2;s=Scalar_Simulation_String" ) ,
488489 AttributeId = Attributes . Value ,
489490 DisplayName = "String Variable" ,
490491 SamplingInterval = itemSamplingInterval ,
@@ -496,7 +497,7 @@ public async Task<bool> SubscribeToDataChangesAsync(
496497
497498 var eventMonitoredItem = new MonitoredItem ( subscription . DefaultItem )
498499 {
499- StartNodeId = new NodeId ( ObjectIds . Server ) ,
500+ StartNodeId = ObjectIds . Server ,
500501 AttributeId = Attributes . EventNotifier ,
501502 DisplayName = "Event Variable" ,
502503 SamplingInterval = itemSamplingInterval ,
@@ -529,7 +530,7 @@ public async Task<bool> SubscribeToDataChangesAsync(
529530 } ;
530531 var desiredEventType = new LiteralOperand
531532 {
532- Value = new Variant ( new NodeId ( ObjectTypeIds . ExclusiveLevelAlarmType ) )
533+ Value = new Variant ( ObjectTypeIds . ExclusiveLevelAlarmType )
533534 } ;
534535
535536 whereClause . Push ( FilterOperator . Equals , [ existingEventType , desiredEventType ] ) ;
@@ -715,7 +716,7 @@ public async Task<IList<INode>> FetchAllNodesNodeCacheAsync(
715716 /// <param name="browseDescription">An optional BrowseDescription to use.</param>
716717 public async Task < ReferenceDescriptionCollection > ManagedBrowseFullAddressSpaceAsync (
717718 IUAClient uaClient ,
718- NodeId startingNode = null ,
719+ NodeId startingNode = default ,
719720 BrowseDescription browseDescription = null ,
720721 CancellationToken ct = default )
721722 {
@@ -891,7 +892,7 @@ await uaClient
891892 /// <param name="browseDescription">An optional BrowseDescription to use.</param>
892893 public async Task < ReferenceDescriptionCollection > BrowseFullAddressSpaceAsync (
893894 IUAClient uaClient ,
894- NodeId startingNode = null ,
895+ NodeId startingNode = default ,
895896 BrowseDescription browseDescription = null ,
896897 CancellationToken ct = default )
897898 {
@@ -990,8 +991,8 @@ BrowseDescriptionCollection browseDescriptionCollection
990991 }
991992 catch ( ServiceResultException sre )
992993 {
993- if ( sre . StatusCode is StatusCodes . BadEncodingLimitsExceeded or StatusCodes
994- . BadResponseTooLarge )
994+ if ( sre . StatusCode == StatusCodes . BadEncodingLimitsExceeded ||
995+ sre . StatusCode == StatusCodes . BadResponseTooLarge )
995996 {
996997 // try to address by overriding operation limit
997998 maxNodesPerBrowse =
@@ -1119,7 +1120,7 @@ public async Task<ComplexTypeSystem> LoadTypeSystemAsync(
11191120 stopWatch . Start ( ) ;
11201121
11211122 var complexTypeSystem = new ComplexTypeSystem ( session , m_telemetry ) ;
1122- await complexTypeSystem . LoadAsync ( ct : ct ) . ConfigureAwait ( false ) ;
1123+ await complexTypeSystem . LoadAsync ( throwOnError : true , ct : ct ) . ConfigureAwait ( false ) ;
11231124
11241125 stopWatch . Stop ( ) ;
11251126
@@ -1775,7 +1776,21 @@ private static ByteStringCollection PrepareBrowseNext(
17751776 return continuationPoints ;
17761777 }
17771778
1778- private readonly Action < IList , IList > m_validateResponse ;
1779+ private void ValidateResponse < TRequest , TResponse > (
1780+ IReadOnlyList < TRequest > requests ,
1781+ IReadOnlyList < TResponse > responses )
1782+ {
1783+ if ( m_validate != null )
1784+ {
1785+ m_validate ( requests ? . ToList ( ) , responses ? . ToList ( ) ) ;
1786+ }
1787+ else
1788+ {
1789+ ClientBase . ValidateResponse ( responses , requests ) ;
1790+ }
1791+ }
1792+
1793+ private readonly Action < IList , IList > m_validate ;
17791794 private readonly ITelemetryContext m_telemetry ;
17801795 private readonly ILogger m_logger ;
17811796 private readonly ManualResetEvent m_quitEvent ;
0 commit comments