Skip to content

Commit 6d52547

Browse files
authored
Move newly introduced AsyncNodeTable and AsyncTypeTree interfaces to core (#3182)
* Move new interfaces to core * Add extension methods to convert from async to sync tables
1 parent 520351c commit 6d52547

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

Libraries/Opc.Ua.Client/NodeCache/NodeCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void Dispose()
8585
/// <summary>
8686
/// Legacy type table adapter for backwards compatibility.
8787
/// </summary>
88-
public ITypeTable TypeTree => new TypeTableAdapter(this);
88+
public ITypeTable TypeTree => this.AsTypeTable();
8989

9090
/// <inheritdoc/>
9191
public async ValueTask<INode> FindAsync(

Libraries/Opc.Ua.Client/NodeCache/IAsyncNodeTable.cs renamed to Stack/Opc.Ua.Core/Stack/Nodes/IAsyncNodeTable.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
1-
/* ========================================================================
2-
* Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved.
3-
*
4-
* OPC Foundation MIT License 1.00
5-
*
6-
* Permission is hereby granted, free of charge, to any person
7-
* obtaining a copy of this software and associated documentation
8-
* files (the "Software"), to deal in the Software without
9-
* restriction, including without limitation the rights to use,
10-
* copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the
12-
* Software is furnished to do so, subject to the following
13-
* conditions:
14-
*
15-
* The above copyright notice and this permission notice shall be
16-
* included in all copies or substantial portions of the Software.
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19-
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22-
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23-
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24-
* OTHER DEALINGS IN THE SOFTWARE.
25-
*
26-
* The complete license agreement can be found here:
27-
* http://opcfoundation.org/License/MIT/1.00/
28-
* ======================================================================*/
1+
/* Copyright (c) 1996-2022 The OPC Foundation. All rights reserved.
2+
The source code in this file is covered under a dual-license scenario:
3+
- RCL: for OPC Foundation Corporate Members in good-standing
4+
- GPL V2: everybody else
5+
RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/
6+
GNU General Public License as published by the Free Software Foundation;
7+
version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2
8+
This source code is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
2912

3013
using System.Collections.Generic;
3114
using System.Threading;
3215
using System.Threading.Tasks;
3316

34-
namespace Opc.Ua.Client
17+
namespace Opc.Ua
3518
{
3619
/// <summary>
3720
/// Async node table methods
@@ -116,6 +99,23 @@ ValueTask<IList<INode>> FindAsync(
11699
CancellationToken ct = default);
117100
}
118101

102+
/// <summary>
103+
/// Node table extensions
104+
/// </summary>
105+
public static class NodeTableExtensions
106+
{
107+
/// <summary>
108+
/// Expose a async node table as a synchronous table to
109+
/// adapt it to code that requires synchronous methods.
110+
/// </summary>
111+
/// <param name="table"></param>
112+
/// <returns></returns>
113+
public static INodeTable AsNodeTable(this IAsyncNodeTable table)
114+
{
115+
return new NodeTableAdapter(table);
116+
}
117+
}
118+
119119
internal sealed class NodeTableAdapter : INodeTable
120120
{
121121
public NodeTableAdapter(IAsyncNodeTable nodeTable)

Libraries/Opc.Ua.Client/NodeCache/IAsyncTypeTable.cs renamed to Stack/Opc.Ua.Core/Stack/Nodes/IAsyncTypeTable.cs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,20 @@
1-
/* ========================================================================
2-
* Copyright (c) 2005-2020 The OPC Foundation, Inc. All rights reserved.
3-
*
4-
* OPC Foundation MIT License 1.00
5-
*
6-
* Permission is hereby granted, free of charge, to any person
7-
* obtaining a copy of this software and associated documentation
8-
* files (the "Software"), to deal in the Software without
9-
* restriction, including without limitation the rights to use,
10-
* copy, modify, merge, publish, distribute, sublicense, and/or sell
11-
* copies of the Software, and to permit persons to whom the
12-
* Software is furnished to do so, subject to the following
13-
* conditions:
14-
*
15-
* The above copyright notice and this permission notice shall be
16-
* included in all copies or substantial portions of the Software.
17-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19-
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22-
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23-
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24-
* OTHER DEALINGS IN THE SOFTWARE.
25-
*
26-
* The complete license agreement can be found here:
27-
* http://opcfoundation.org/License/MIT/1.00/
28-
* ======================================================================*/
1+
/* Copyright (c) 1996-2022 The OPC Foundation. All rights reserved.
2+
The source code in this file is covered under a dual-license scenario:
3+
- RCL: for OPC Foundation Corporate Members in good-standing
4+
- GPL V2: everybody else
5+
RCL license terms accompanied with this source code. See http://opcfoundation.org/License/RCL/1.00/
6+
GNU General Public License as published by the Free Software Foundation;
7+
version 2 of the License are accompanied with this source code. See http://opcfoundation.org/License/GPLv2
8+
This source code is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11+
*/
2912

3013
using System.Collections.Generic;
3114
using System.Threading;
3215
using System.Threading.Tasks;
3316

34-
namespace Opc.Ua.Client
17+
namespace Opc.Ua
3518
{
3619
/// <summary>
3720
/// Caches the type tree of the server on the client side.
@@ -216,6 +199,23 @@ ValueTask<NodeId> FindDataTypeIdAsync(
216199
CancellationToken ct = default);
217200
}
218201

202+
/// <summary>
203+
/// Type table extensions
204+
/// </summary>
205+
public static class TypeTableExtensions
206+
{
207+
/// <summary>
208+
/// Expose a async type table as a synchronous table to
209+
/// adapt it to code that requires synchronous methods.
210+
/// </summary>
211+
/// <param name="table"></param>
212+
/// <returns></returns>
213+
public static ITypeTable AsTypeTable(this IAsyncTypeTable table)
214+
{
215+
return new TypeTableAdapter(table);
216+
}
217+
}
218+
219219
/// <summary>
220220
/// Type table adapter for synchronous access to the table.
221221
/// We need to keep the sync interface for now as it is shared

0 commit comments

Comments
 (0)