Beispiel #1
0
 /// <summary>
 /// Validates the specified <see cref="IIndexUser"/>.
 /// The <paramref name="user"/> is added to <see cref="_users"/>
 /// if the user isn't known by the current <see cref="IndexGenerator"/>.
 /// </summary>
 /// <param name="user"></param>
 private void RegisterUser(IIndexUser user)
 {
     using (_usersLock.EnterDisposableUpgradeableReadLock())
         if (!_users.Contains(user))
         {
             using (_usersLock.EnterDisposableWriteLock())
                 _users.Add(user);
         }
 }
Beispiel #2
0
 /// <summary>
 /// Adds an alias for an already known handle.
 /// </summary>
 /// <exception cref="ArgumentException">
 /// An <see cref="ArgumentException"/> is thrown if <paramref name="hKey"/>
 /// is unknown the the current <see cref="RegistryBase"/>.
 /// </exception>
 /// <exception cref="ApplicationException">
 /// The key handle to alias already exists in the virtual registry.
 /// = OR =
 /// An uncompatible alias already exists for an other virtual key.
 /// </exception>
 /// <param name="hKey">The virtual key handle, known by the current <see cref="RegistryBase"/>.</param>
 /// <param name="aliasHKey">The handle to add as alias for <paramref name="hKey"/>.</param>
 public void AddAlias(uint hKey, uint aliasHKey)
 {
     using (_keysSynchronizationLock.EnterDisposableUpgradeableReadLock())
     {
         hKey = EnsureHandleIsNoAlias(hKey);
         if (!_keys.ContainsKey(hKey))
         {
             throw new ArgumentException("The handle specified is unknown to the current RegistryBase.", "hKey");
         }
         if (!_keyAliases.ContainsKey(aliasHKey))
         {
             if (_indexGenerator.IsInUse(aliasHKey))
             {
                 throw new ApplicationException("The alias key handle already exists in the virtual registry.");
             }
             using (_keysSynchronizationLock.EnterDisposableWriteLock())
                 _keyAliases.Add(aliasHKey, hKey);
         }
         else if (_keyAliases[aliasHKey] != hKey)
         {
             throw new ApplicationException("An incompatible alias already exists for an other virtual key.");
         }
     }
 }