// Create a subkey underneath this particular registry key. public IRegistryKeyProvider CreateSubKey(String subkey) { lock(this) { if(deleted) { throw new ArgumentException (_("IO_RegistryKeyNotExist")); } if(subkeys == null) { subkeys = new Hashtable (CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); } Object value = subkeys[subkey]; if(value == null) { value = new MemoryKeyProvider (this, name + "\\" + subkey, subkey); subkeys[subkey] = value; } return (IRegistryKeyProvider)value; } }
// Create a subkey underneath this particular registry key. public IRegistryKeyProvider CreateSubKey(String subkey) { lock (this) { if (deleted) { throw new ArgumentException (_("IO_RegistryKeyNotExist")); } if (subkeys == null) { subkeys = new Hashtable (CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default); } Object value = subkeys[subkey]; if (value == null) { value = new MemoryKeyProvider (this, name + "\\" + subkey, subkey); subkeys[subkey] = value; } return((IRegistryKeyProvider)value); } }
// Constructor. public MemoryKeyProvider(MemoryKeyProvider parent, String fullName, String name) { this.parent = parent; this.fullName = fullName; this.name = name; this.subkeys = null; this.values = null; this.deleted = false; }
// Constructor. public MemoryKeyProvider(MemoryKeyProvider parent, String fullName, String name) { this.parent = parent; this.fullName = fullName; this.name = name; this.subkeys = null; this.values = null; this.deleted = false; }
// Get a registry key provider for a particular hive. internal static IRegistryKeyProvider GetProvider (RegistryHive hKey, String name) { int index; lock (typeof(Registry)) { // Allocate the "providers" array if necessary. if (providers == null) { providers = new IRegistryKeyProvider[7]; } // See if we already have a provider for this hive. index = ((int)hKey) - ((int)(RegistryHive.ClassesRoot)); if (providers[index] != null) { return(providers[index]); } // Create a Win32 provider if we are on a Windows system. if (Win32KeyProvider.IsWin32()) { providers[index] = new Win32KeyProvider (name, Win32KeyProvider.HiveToHKey(hKey)); return(providers[index]); } // Try to create a file-based provider for the hive. try { providers[index] = new FileKeyProvider(hKey, name); return(providers[index]); } catch (NotSupportedException) { // Could not create the hive directory - fall through. } // Create a memory-based provider on all other systems. providers[index] = new MemoryKeyProvider (null, name, name); return(providers[index]); } }
// Delete this key entry. public void Delete() { MemoryKeyProvider parent; // Delete the information in this entry. lock (this) { if (deleted) { // This key was already deleted. throw new ArgumentException (_("IO_RegistryKeyNotExist")); } else if (subkeys != null && subkeys.Count != 0) { throw new InvalidOperationException (_("IO_RegistryHasSubKeys")); } else { deleted = true; subkeys = null; if (values != null && values.Count != 0) { values.Clear(); } values = null; } parent = this.parent; } // Remove the name from the parent provider. if (parent != null) { lock (parent) { if (parent.subkeys != null) { parent.subkeys.Remove(name); } } } }
// Delete this key entry. public void Delete() { MemoryKeyProvider parent; // Delete the information in this entry. lock(this) { if(deleted) { // This key was already deleted. throw new ArgumentException (_("IO_RegistryKeyNotExist")); } else if(subkeys != null && subkeys.Count != 0) { throw new InvalidOperationException (_("IO_RegistryHasSubKeys")); } else { deleted = true; subkeys = null; if(values != null && values.Count != 0) { values.Clear(); } values = null; } parent = this.parent; } // Remove the name from the parent provider. if(parent != null) { lock(parent) { if(parent.subkeys != null) { parent.subkeys.Remove(name); } } } }
// Get a registry key provider for a particular hive. internal static IRegistryKeyProvider GetProvider (RegistryHive hKey, String name) { int index; lock(typeof(Registry)) { // Allocate the "providers" array if necessary. if(providers == null) { providers = new IRegistryKeyProvider[7]; } // See if we already have a provider for this hive. index = ((int)hKey) - ((int)(RegistryHive.ClassesRoot)); if(providers[index] != null) { return providers[index]; } // Create a Win32 provider if we are on a Windows system. if(Win32KeyProvider.IsWin32()) { providers[index] = new Win32KeyProvider (name, Win32KeyProvider.HiveToHKey(hKey)); return providers[index]; } // Try to create a file-based provider for the hive. try { providers[index] = new FileKeyProvider(hKey, name); return providers[index]; } catch(NotSupportedException) { // Could not create the hive directory - fall through. } // Create a memory-based provider on all other systems. providers[index] = new MemoryKeyProvider (null, name, name); return providers[index]; } }