Пример #1
0
        // Constructors.
        private FileKeyProvider(FileKeyProvider parent, String name)
        {
            // Record the name information for later.
            this.fullName = parent.fullName + "\\" + name;

            // Build the full pathname for the directory.
            this.directory =
                parent.directory + Path.DirectorySeparatorChar + name;
        }
Пример #2
0
        // 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]);
            }
        }
Пример #3
0
	// 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];
				}
			}
	// Constructors.
	private FileKeyProvider(FileKeyProvider parent, String name)
			{
				// Record the name information for later.
				this.fullName = parent.fullName + "\\" + name;

				// Build the full pathname for the directory.
				this.directory =
					parent.directory + Path.DirectorySeparatorChar + name;
			}