/// <summary> /// Exports a server index. /// </summary> private uint ImportServerIndex(uint serverIndex, StringTable serverUris) { // nothing special required for indexes 0. if (serverIndex <= 0) { return(serverIndex); } // return a bad value if parameters are bad. if (serverUris == null || this.ServerUris == null || this.ServerUris.Length <= serverIndex - 1) { return(UInt16.MaxValue); } // find or append uri. return(serverUris.GetIndexOrAppend(this.ServerUris[serverIndex - 1])); }
/// <summary> /// Initializes the mapper. /// </summary> /// <param name="localNamespaceUris"></param> /// <param name="remoteNamespaceUris"></param> public void Initialize(StringTable localNamespaceUris, StringTable remoteNamespaceUris, string applicationUri) { m_localNamespaceIndexes = new int[remoteNamespaceUris.Count]; for (int ii = 1; ii < remoteNamespaceUris.Count; ii++) { string namespaceUri = remoteNamespaceUris.GetString((uint)ii); bool isTypeSystemUri = false; if (TypeSystemNamespaceUris != null) { for (int jj = 0; jj < TypeSystemNamespaceUris.Length; jj++) { if (TypeSystemNamespaceUris[jj] == namespaceUri) { isTypeSystemUri = true; break; } } } if (!isTypeSystemUri) { namespaceUri = applicationUri + ":" + namespaceUri; } m_localNamespaceIndexes[ii] = localNamespaceUris.GetIndexOrAppend(namespaceUri); } m_remoteNamespaceIndexes = new int[localNamespaceUris.Count]; for (int ii = 0; ii < m_localNamespaceIndexes.Length; ii++) { if (m_remoteNamespaceIndexes.Length > m_localNamespaceIndexes[ii]) { m_remoteNamespaceIndexes[m_localNamespaceIndexes[ii]] = ii; } } }
/// <summary> /// compares the new server namespace table with the (saved) table known to the client. Provides a /// mapping for any namespaces which are new or removed and indices which have changed. /// </summary> /// <param name="clsid"></param> private void GenerateNamespaceIndexMappings(Guid clsid) { try { StringTable savedStringTable = new StringTable(); for (int i = 0; i < m_configFile.SavedNamespaceTable.Length; i++) savedStringTable.Append(m_configFile.SavedNamespaceTable[i]); NamespaceTable serverNamespaceTable = m_session.NamespaceUris; string[] serverNamespaceArray = serverNamespaceTable.ToArray(); for (int i = 0; i < serverNamespaceArray.Length; i++) { // Generate the serverIndex->clientIndex mapping table. Update the client namespace // table in the process if new namespaces have been added to the server namespace m_serverMappingTable.Add(savedStringTable.GetIndexOrAppend(serverNamespaceArray[i])); } m_configFile.SavedNamespaceTable = savedStringTable.ToArray(); for (int i = 0; i < m_configFile.SavedNamespaceTable.Length; i++) { // Generate the clientIndex->serverIndex mapping table m_clientmappingTable.Add(serverNamespaceTable.GetIndex(m_configFile.SavedNamespaceTable[i])); } } catch (Exception e) { Utils.Trace(e, "Unexpected error in InitNamespaceMappingTable"); } }
/// <summary> /// Exports a server index. /// </summary> private uint ImportServerIndex(uint serverIndex, StringTable serverUris) { // nothing special required for indexes 0. if (serverIndex <= 0) { return serverIndex; } // return a bad value if parameters are bad. if (serverUris == null || this.ServerUris == null || this.ServerUris.Length <= serverIndex-1) { return UInt16.MaxValue; } // find or append uri. return serverUris.GetIndexOrAppend(this.ServerUris[serverIndex - 1]); }