本文整理汇总了C#中Opc.Ua.NamespaceTable.GetIndexOrAppend方法的典型用法代码示例。如果您正苦于以下问题:C# NamespaceTable.GetIndexOrAppend方法的具体用法?C# NamespaceTable.GetIndexOrAppend怎么用?C# NamespaceTable.GetIndexOrAppend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opc.Ua.NamespaceTable
的用法示例。
在下文中一共展示了NamespaceTable.GetIndexOrAppend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateNamespaceTable
/// <summary>
/// Updates the namespace table with URI used in the relative path.
/// </summary>
/// <param name="currentTable">The current table.</param>
/// <param name="targetTable">The target table.</param>
public void UpdateNamespaceTable(NamespaceTable currentTable, NamespaceTable targetTable)
{
// build mapping table.
int[] mappings = new int[currentTable.Count];
mappings[0] = 0;
if (mappings.Length > 0)
{
mappings[1] = 1;
}
// ensure a placeholder for the local namespace.
if (targetTable.Count <= 1)
{
targetTable.Append("---");
}
string[] uris = new string[mappings.Length];
for (int ii = 2; ii < mappings.Length; ii++)
{
uris[ii] = currentTable.GetString((uint)ii);
if (uris[ii] != null)
{
mappings[ii] = targetTable.GetIndex(uris[ii]);
}
}
// update each element.
foreach (Element element in m_elements)
{
// check reference type name.
QualifiedName qname = element.ReferenceTypeName;
if (qname != null && qname.NamespaceIndex > 1)
{
if (qname.NamespaceIndex < mappings.Length)
{
if (mappings[qname.NamespaceIndex] == -1)
{
mappings[qname.NamespaceIndex] = targetTable.GetIndexOrAppend(uris[qname.NamespaceIndex]);
}
}
}
// check target name.
qname = element.TargetName;
if (qname != null && qname.NamespaceIndex > 1)
{
if (qname.NamespaceIndex < mappings.Length)
{
if (mappings[qname.NamespaceIndex] == -1)
{
mappings[qname.NamespaceIndex] = targetTable.GetIndexOrAppend(uris[qname.NamespaceIndex]);
}
}
}
}
}
示例2: ImportNamespaceIndex
/// <summary>
/// Exports a namespace index.
/// </summary>
private ushort ImportNamespaceIndex(ushort namespaceIndex, NamespaceTable namespaceUris)
{
// nothing special required for indexes 0 and 1.
if (namespaceIndex < 1)
{
return namespaceIndex;
}
// return a bad value if parameters are bad.
if (namespaceUris == null || this.NamespaceUris == null || this.NamespaceUris.Length <= namespaceIndex - 1)
{
return UInt16.MaxValue;
}
// find or append uri.
return namespaceUris.GetIndexOrAppend(this.NamespaceUris[namespaceIndex - 1]);
}