本文整理匯總了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]);
}