/* ======================================================================== * Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved. * * OPC Foundation MIT License 1.00 * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * The complete license agreement can be found here: * http://opcfoundation.org/License/MIT/1.00/ * ======================================================================*/ using System; using System.Collections.Generic; namespace Opc.Ua.Server.AliasNames { /// /// Configuration describing a single OPC UA Part 17 alias. An alias maps /// a human-readable name (within its containing /// ) to one or more target nodes /// reached via a specific reference type. /// /// /// /// The wire-level representation is AliasNameDataType (Part 17 /// §7.2) — a and a list of /// targets. The /// is the reference type used between the AliasName object and /// each target node in the server's address space; it also drives the /// ReferenceTypeFilter argument of the FindAlias methods /// (Part 17 §6.3.2). /// /// /// is the optional list of server URIs used by /// the verbose form AliasNameVerboseDataType (Part 17 §7.3). When /// present, ServerUris[i] identifies the server hosting /// ReferencedNodes[i]; an empty entry, or a list shorter than /// ReferencedNodes, means "the current server". /// /// public sealed record AliasDefinition { /// /// Initializes a new alias definition. /// /// The alias name as a ; /// the NamespaceIndex should belong to the node manager's /// namespace. /// The (one or more) /// s the alias resolves to. /// The reference type that connects the /// alias node to each referenced node; typically /// ReferenceTypeIds.AliasFor but may be any non-hierarchical /// reference (per Part 17 §8.2). /// Optional per-target server URIs for the /// verbose form. null means "all targets live on the current /// server". public AliasDefinition( QualifiedName name, IReadOnlyList referencedNodes, NodeId referenceTypeId, IReadOnlyList? serverUris = null) { if (referencedNodes == null) { throw new ArgumentNullException(nameof(referencedNodes)); } if (name.IsNull) { throw new ArgumentException( "AliasName must not be null.", nameof(name)); } if (referencedNodes.Count == 0) { throw new ArgumentException( "At least one referenced node is required.", nameof(referencedNodes)); } if (referenceTypeId.IsNull) { throw new ArgumentException( "ReferenceTypeId must not be null.", nameof(referenceTypeId)); } if (serverUris != null && serverUris.Count > referencedNodes.Count) { throw new ArgumentException( "ServerUris must not be longer than ReferencedNodes.", nameof(serverUris)); } Name = name; ReferencedNodes = referencedNodes; ReferenceTypeId = referenceTypeId; ServerUris = serverUris; } /// /// The alias name. Equality across aliases inside a category is /// determined by the case-sensitive name (per Part 17 wildcard /// semantics) and namespace index. /// public QualifiedName Name { get; } /// /// One or more target nodes the alias resolves to. /// public IReadOnlyList ReferencedNodes { get; } /// /// The reference type connecting the alias to each target. Used both /// to construct the address-space references and to filter result /// sets in FindAlias/FindAliasVerbose. /// public NodeId ReferenceTypeId { get; } /// /// Optional per-target server URIs used by the verbose form. May be /// null (all targets on the local server) or shorter than /// (trailing entries default to the /// local server). /// public IReadOnlyList? ServerUris { get; } } }