PHP.Core.CompilerConfiguration.LoadFromFile C# (CSharp) Method

LoadFromFile() public method

Loads compiler configuration values from a specified .config file into a given record.
An error in configuration.
public LoadFromFile ( PHP.Core.ApplicationContext appContext, FullPath path ) : void
appContext PHP.Core.ApplicationContext Application context where to load libraries.
path FullPath A full path to the .config file.
return void
        public void LoadFromFile(ApplicationContext/*!*/ appContext, FullPath path)
		{
			if (appContext == null)
				throw new ArgumentNullException("appContext");

			path.EnsureNonEmpty("path");

			ConfigXmlDocument doc = new ConfigXmlDocument();

			try
			{
				doc.Load(path);
			}
			catch (XmlException e)
			{
				throw new ConfigurationErrorsException(e.Message);
			}

			XmlNode root = doc.DocumentElement;
            if (root.Name == "configuration")
            {
                ProcessNodes(appContext, root, addedLibraries);
            }
		}

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Loads configuration from Machine.config, phpc.exe.config, from files specified by command line arguments,
        /// and from command line arguments themselves.
        /// </summary>
        /// <exception cref="ConfigurationErrorsException">An error occured while loading the configuration.</exception>
        public static CompilerConfiguration/*!*/ LoadConfiguration(
            ApplicationContext/*!*/ appContext, List<FullPath>/*!*/ paths, TextWriter output)
        {
            Configuration.IsBuildTime = true;

            Configuration.Reload(appContext, true);

            // Machine.config, phpc.exe.config:
            CompilerConfiguration result = new CompilerConfiguration(Configuration.Application);

            // explicitly specified or default configs:
            foreach (FullPath path in paths)
            {
                if (output != null) output.WriteLine(path);
                result.LoadFromFile(appContext, path);
            }

            // load libraries lazily
            result.LoadLibraries(appContext);

            //
            return result;
        }