public ManageableConfigurationSourceImplementation GetInstance(String configurationFilePath,
			IDictionary<String, ConfigurationSectionManageabilityProvider> manageabilityProviders,
			bool readGroupPolicies,
			bool generateWmiObjects,
			String applicationName)
		{
			if (String.IsNullOrEmpty(configurationFilePath))
				throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFilePath");

			String rootedConfigurationFilePath = RootConfigurationFilePath(configurationFilePath);

			if (!File.Exists(rootedConfigurationFilePath))
				throw new FileNotFoundException(String.Format(Resources.Culture, Resources.ExceptionConfigurationLoadFileNotFound, rootedConfigurationFilePath));

			ImplementationKey key = new ImplementationKey(rootedConfigurationFilePath, applicationName, readGroupPolicies);
			ManageableConfigurationSourceImplementation instance;

			lock (lockObject)
			{
				instances.TryGetValue(key, out instance);
				if (instance == null)
				{
					instance = new ManageableConfigurationSourceImplementation(rootedConfigurationFilePath,
						refresh,
						manageabilityProviders,
						readGroupPolicies,
						generateWmiObjects,
						applicationName);
					instances.Add(key, instance);
				}
			}

			return instance;
		}
Пример #2
0
        public ManageableConfigurationSourceImplementation GetInstance(String configurationFilePath,
                                                                       IDictionary <String, ConfigurationSectionManageabilityProvider> manageabilityProviders,
                                                                       bool readGroupPolicies,
                                                                       bool generateWmiObjects,
                                                                       String applicationName)
        {
            if (String.IsNullOrEmpty(configurationFilePath))
            {
                throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFilePath");
            }

            String rootedConfigurationFilePath = RootConfigurationFilePath(configurationFilePath);

            if (!File.Exists(rootedConfigurationFilePath))
            {
                throw new FileNotFoundException(String.Format(Resources.Culture, Resources.ExceptionConfigurationLoadFileNotFound, rootedConfigurationFilePath));
            }

            ImplementationKey key = new ImplementationKey(rootedConfigurationFilePath, applicationName, readGroupPolicies);
            ManageableConfigurationSourceImplementation instance;

            lock (lockObject)
            {
                instances.TryGetValue(key, out instance);
                if (instance == null)
                {
                    instance = new ManageableConfigurationSourceImplementation(rootedConfigurationFilePath,
                                                                               refresh,
                                                                               manageabilityProviders,
                                                                               readGroupPolicies,
                                                                               generateWmiObjects,
                                                                               applicationName);
                    instances.Add(key, instance);
                }
            }

            return(instance);
        }
 public ManageableConfigurationSourceImplementation GetInstance(string configurationFilePath, IDictionary<string, ConfigurationSectionManageabilityProvider> manageabilityProviders, bool readGroupPolicies, bool generateWmiObjects, string applicationName)
 {
     ManageableConfigurationSourceImplementation implementation;
     if (string.IsNullOrEmpty(configurationFilePath))
     {
         throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFilePath");
     }
     string path = RootConfigurationFilePath(configurationFilePath);
     if (!File.Exists(path))
     {
         throw new FileNotFoundException(string.Format(Resources.Culture, Resources.ExceptionConfigurationLoadFileNotFound, new object[] { path }));
     }
     ImplementationKey key = new ImplementationKey(path, applicationName, readGroupPolicies);
     lock (this.lockObject)
     {
         this.instances.TryGetValue(key, out implementation);
         if (implementation == null)
         {
             implementation = new ManageableConfigurationSourceImplementation(path, this.refresh, manageabilityProviders, readGroupPolicies, generateWmiObjects, applicationName);
             this.instances.Add(key, implementation);
         }
     }
     return implementation;
 }