Opc.Ua.Com.Server.ComNamespaceMapper.StringTableMapping.InitializeRemoteToLocalMapping C# (CSharp) Method

InitializeRemoteToLocalMapping() private method

Initializes the remote to local mapping for a pair of string tables.
private InitializeRemoteToLocalMapping ( List localTable, StringTable remoteTable ) : int[]
localTable List The local table.
remoteTable StringTable The remote table.
return int[]
            private int[] InitializeRemoteToLocalMapping(List<string> localTable, StringTable remoteTable)
            {
                List<int> indexes = new List<int>();
                indexes.Add(0);

                if (remoteTable is NamespaceTable)
                {
                    indexes.Add(1);
                }

                int start = indexes.Count;

                for (int ii = start; ii < remoteTable.Count; ii++)
                {
                    string uri = remoteTable.GetString((uint)ii);

                    // look for the matching local index.
                    bool found = false;

                    for (int jj = 0; jj < localTable.Count; jj++)
                    {
                        if (localTable[jj] == uri)
                        {
                            found = true;
                            indexes.Add(jj+start);
                            break;
                        }
                    }

                    // not found.
                    if (!found)
                    {
                        localTable.Add(uri);
                        indexes.Add(localTable.Count-1+start);
                    }
                }

                // return the indexes.
                return indexes.ToArray();
            }
            #endregion