コード例 #1
0
        static public CompilationConfiguration GetInstance(HttpContext context)
        {
            CompilationConfiguration config;

            if (context == null)
            {
                context = HttpContext.Current;
            }

            if (context != null)
            {
                config = context.GetConfig("system.web/compilation") as CompilationConfiguration;
                if (config == null)
                {
                    throw new Exception("Configuration error.");
                }
            }
            else
            {
                // empty config (as used in unit tests)
                config = new CompilationConfiguration(null);
            }

            return(config);
        }
コード例 #2
0
        static void ReadCompilers(XmlNodeList nodes, CompilationConfiguration config)
        {
            foreach (XmlNode child in nodes)
            {
                XmlNodeType ntype = child.NodeType;
                if (ntype != XmlNodeType.Element)
                {
                    continue;
                }

                if (child.Name != "compiler")
                {
                    ThrowException("Unexpected element", child);
                }

                Compiler compiler = new Compiler();
                compiler.Language        = AttValue("language", child);
                compiler.Extension       = AttValue("extension", child);
                compiler.Type            = AttValue("type", child);
                compiler.CompilerOptions = AttValue("compilerOptions", child, true, true);
                compiler.WarningLevel    = AttUIntValue("warningLevel", child, 0);
#if NET_2_0
                config.Compilers.Add(compiler);
#else
                config.Compilers [compiler.Language] = compiler;
#endif
            }
        }
コード例 #3
0
        public object Create(object parent, object context, XmlNode section)
        {
            CompilationConfiguration config = new CompilationConfiguration(parent);

            string tmp = AttValue("tempDirectory", section, true);

            if (tmp != null && tmp != "")
            {
                config.TempDirectory = tmp;
            }
            config.DefaultLanguage = AttValue("defaultLanguage", section);
            if (config.DefaultLanguage == null)
            {
                config.DefaultLanguage = "c#";
            }

            config.Debug            = AttBoolValue("debug", section, false);
            config.Batch            = AttBoolValue("batch", section, false);
            config.Explicit         = AttBoolValue("explicit", section, true);
            config.Strict           = AttBoolValue("strict", section, false);
            config.BatchTimeout     = AttUIntValue("batchTimeout", section, 0);
            config.MaxBatchSize     = AttUIntValue("maxBatchSize", section, 0);
            config.MaxBatchFileSize = AttUIntValue("maxBatchFileSize", section, 0);
            config.NumRecompilesBeforeAppRestart =
                AttUIntValue("numRecompilesBeforeAppRestart", section, 15);

            if (section.Attributes != null && section.Attributes.Count != 0)
            {
                ThrowException("Unrecognized attribute.", section);
            }

            XmlNodeList authNodes = section.ChildNodes;

            foreach (XmlNode child in authNodes)
            {
                XmlNodeType ntype = child.NodeType;
                if (ntype != XmlNodeType.Element)
                {
                    continue;
                }

                if (child.Name == "compilers")
                {
                    ReadCompilers(child.ChildNodes, config);
                    continue;
                }

                if (child.Name == "assemblies")
                {
                    ReadAssemblies(child.ChildNodes, config);
                    continue;
                }

                ThrowException("Unexpected element", child);
            }

            return(config);
        }
コード例 #4
0
        static void ReadAssemblies(XmlNodeList nodes, CompilationConfiguration config)
        {
            ArrayList assemblies = config.Assemblies;

            foreach (XmlNode child in nodes)
            {
                XmlNodeType ntype = child.NodeType;
                if (ntype != XmlNodeType.Element)
                {
                    continue;
                }

                if (child.Name == "clear")
                {
                    assemblies.Clear();
                    config.AssembliesInBin = false;
                    continue;
                }

                string aname = AttValue("assembly", child);
                if (child.Name == "add")
                {
                    if (aname == "*")
                    {
                        config.AssembliesInBin = true;
                        continue;
                    }

                    if (!assemblies.Contains(aname))
                    {
                        assemblies.Add(aname);
                    }

                    continue;
                }

                if (child.Name == "remove")
                {
                    if (aname == "*")
                    {
                        config.AssembliesInBin = false;
                        continue;
                    }
                    assemblies.Remove(aname);
                    continue;
                }

                ThrowException("Unexpected element " + child.Name, child);
            }
        }
		public object Create (object parent, object context, XmlNode section)
		{
			CompilationConfiguration config = new CompilationConfiguration (parent);

			string tmp = AttValue ("tempDirectory", section, true);
			if (tmp != null && tmp != "")
				config.TempDirectory = tmp;
			config.DefaultLanguage = AttValue ("defaultLanguage", section);
			if (config.DefaultLanguage == null)
				config.DefaultLanguage = "c#";

			config.Debug = AttBoolValue ("debug", section, false);
			config.Batch = AttBoolValue ("batch", section, false);
			config.Explicit = AttBoolValue ("explicit", section, true);
			config.Strict = AttBoolValue ("strict", section, false);
			config.BatchTimeout = AttUIntValue ("batchTimeout", section, 0);
			config.MaxBatchSize = AttUIntValue ("maxBatchSize", section, 0);
			config.MaxBatchFileSize = AttUIntValue ("maxBatchFileSize", section, 0);
			config.NumRecompilesBeforeAppRestart =
					AttUIntValue ("numRecompilesBeforeAppRestart", section, 15);

			if (section.Attributes != null && section.Attributes.Count != 0)
				ThrowException ("Unrecognized attribute.", section);

			XmlNodeList authNodes = section.ChildNodes;
			foreach (XmlNode child in authNodes) {
				XmlNodeType ntype = child.NodeType;
				if (ntype != XmlNodeType.Element)
					continue;
				
				if (child.Name == "compilers") {
					ReadCompilers (child.ChildNodes, config);
					continue;
				}

				if (child.Name == "assemblies") {
					ReadAssemblies (child.ChildNodes, config);
					continue;
				}

				ThrowException ("Unexpected element", child);
			}

			return config;
		}
コード例 #6
0
		static void ReadCompilers (XmlNodeList nodes, CompilationConfiguration config)
		{
			foreach (XmlNode child in nodes) {
				XmlNodeType ntype = child.NodeType;
				if (ntype != XmlNodeType.Element)
					continue;

				if (child.Name != "compiler")
					ThrowException ("Unexpected element", child);

				Compiler compiler = new Compiler ();
				compiler.Language  = AttValue ("language", child);
				compiler.Extension  = AttValue ("extension", child);
				compiler.Type = AttValue ("type", child);
				compiler.CompilerOptions = AttValue ("compilerOptions", child, true, true);
				compiler.WarningLevel = AttUIntValue ("warningLevel", child, 0);
				config.Compilers [compiler.Language] = compiler;
			}
		}
コード例 #7
0
        void Init(CompilationConfiguration parent)
        {
            debug               = parent.debug;
            batch               = parent.batch;
            batch_timeout       = parent.batch_timeout;
            default_language    = parent.default_language;
            _explicit           = parent._explicit;
            max_batch_size      = parent.max_batch_size;
            max_batch_file_size = parent.max_batch_file_size;
            num_recompiles_before_app_restart = parent.num_recompiles_before_app_restart;
            strict         = parent.strict;
            temp_directory = parent.temp_directory;
#if NET_2_0
            compilers = new CompilerCollection();
#else
            compilers = new CompilerCollection(parent.compilers);
#endif
            ArrayList p = parent.assemblies;
            assembliesInBin = parent.assembliesInBin;
            ICollection coll = (p == null) ? (ICollection) new object [0] : p;
            assemblies = new ArrayList(coll);
        }
コード例 #8
0
        /* Only the config. handler should create instances of this. Use GetInstance (context) */
        public CompilationConfiguration(object p)
        {
            CompilationConfiguration parent = p as CompilationConfiguration;

            if (parent != null)
            {
                Init(parent);
            }

            if (compilers == null)
            {
                compilers = new CompilerCollection();
            }

            if (assemblies == null)
            {
                assemblies = new ArrayList();
            }

            if (temp_directory == null || temp_directory == "")
            {
                temp_directory = AppDomain.CurrentDomain.SetupInformation.DynamicBase;
            }
        }
コード例 #9
0
		void Init (CompilationConfiguration parent)
		{
			debug = parent.debug;
			batch = parent.batch;
			batch_timeout = parent.batch_timeout;
			default_language = parent.default_language;
			_explicit = parent._explicit;
			max_batch_size = parent.max_batch_size;
			max_batch_file_size = parent.max_batch_file_size;
			num_recompiles_before_app_restart = parent.num_recompiles_before_app_restart;
			strict = parent.strict;
			temp_directory = parent.temp_directory;
			compilers = new CompilerCollection (parent.compilers);
			ArrayList p = parent.assemblies;
			assembliesInBin = parent.assembliesInBin;
			ICollection coll = (p == null) ? (ICollection) new object [0] : p;
			assemblies = new ArrayList (coll);
		}
コード例 #10
0
		static void ReadAssemblies (XmlNodeList nodes, CompilationConfiguration config)
		{
			ArrayList assemblies = config.Assemblies;

			foreach (XmlNode child in nodes) {
				XmlNodeType ntype = child.NodeType;
				if (ntype != XmlNodeType.Element)
					continue;

				if (child.Name == "clear") {
					assemblies.Clear ();
					config.AssembliesInBin = false;
					continue;
				}

				string aname = AttValue ("assembly", child);
				if (child.Name == "add") {
					if (aname == "*") {
						config.AssembliesInBin = true;
						continue;
					}

					if (!assemblies.Contains (aname))
						assemblies.Add (aname);

					continue;
				}

				if (child.Name == "remove") {
					if (aname == "*") {
						config.AssembliesInBin = false;
						continue;
					}
					assemblies.Remove (aname);
					continue;
				}

				ThrowException ("Unexpected element " + child.Name, child);
			}
		}
コード例 #11
0
		static public CompilationConfiguration GetInstance (HttpContext context)
		{
			CompilationConfiguration config;
			if (context == null)
				context = HttpContext.Current;

			if (context != null) {
				config = context.GetConfig ("system.web/compilation") as CompilationConfiguration;
				if (config == null)
					throw new Exception ("Configuration error.");
			} else {
				// empty config (as used in unit tests)
				config = new CompilationConfiguration (null);
			}

			return config;
		}