static private CheckForUnrecognizedAttributes ( |
||
node | ||
return | void |
internal static object CreateStatic(object inheritedObject, XmlNode node) { CodeDomCompilationConfiguration inherited = (CodeDomCompilationConfiguration)inheritedObject; CodeDomCompilationConfiguration result; if (inherited == null) { result = new CodeDomCompilationConfiguration(); } else { result = new CodeDomCompilationConfiguration(inherited); } HandlerBase.CheckForUnrecognizedAttributes(node); // // Handle child elements (if they exist) // - compilers // foreach (XmlNode child in node.ChildNodes) { // skip whitespace and comments // reject nonelements if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child)) { continue; } // handle <compilers> if (child.Name == "compilers") { ProcessCompilersElement(result, child); } else { HandlerBase.ThrowUnrecognizedElement(child); } } return(result); }
private static IDictionary <string, string> GetProviderOptions(XmlNode compilerNode) { Dictionary <string, string> res = new Dictionary <string, string>(); foreach (XmlNode child in compilerNode) { if (child.Name != "providerOption") { HandlerBase.ThrowUnrecognizedElement(child); } string name = null, value = null; HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "name", ref name); HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "value", ref value); HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForChildNodes(child); res[name] = value; } return(res); }
private static void ProcessCompilersElement(CodeDomCompilationConfiguration result, XmlNode node) { // reject attributes HandlerBase.CheckForUnrecognizedAttributes(node); String configFile = ConfigurationErrorsException.GetFilename(node); foreach (XmlNode child in node.ChildNodes) { int configLineNumber = ConfigurationErrorsException.GetLineNumber(child); // skip whitespace and comments // reject nonelements if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child)) { continue; } if (child.Name != "compiler") { HandlerBase.ThrowUnrecognizedElement(child); } String languages = String.Empty; XmlNode languageNode = HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "language", ref languages); String extensions = String.Empty; HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "extension", ref extensions); String compilerTypeName = null; HandlerBase.GetAndRemoveRequiredNonEmptyStringAttribute(child, "type", ref compilerTypeName); // Create a CompilerParameters for this compiler. CompilerParameters compilerParams = new CompilerParameters(); int warningLevel = 0; if (HandlerBase.GetAndRemoveNonNegativeIntegerAttribute(child, "warningLevel", ref warningLevel) != null) { compilerParams.WarningLevel = warningLevel; // Need to be false if the warning level is 0 compilerParams.TreatWarningsAsErrors = (warningLevel > 0); } String compilerOptions = null; if (HandlerBase.GetAndRemoveStringAttribute(child, "compilerOptions", ref compilerOptions) != null) { compilerParams.CompilerOptions = compilerOptions; } HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForChildNodes(child); // Create a CompilerInfo structure for this compiler CompilerInfo compilerInfo = new CompilerInfo(compilerParams, compilerTypeName); compilerInfo.configFileName = configFile; compilerInfo.configFileLineNumber = configLineNumber; // Parse the semicolon separated lists string[] languageList = languages.Split(s_fieldSeparators); string[] extensionList = extensions.Split(s_fieldSeparators); for (int i = 0; i < languageList.Length; i++) { languageList[i] = languageList[i].Trim(); } for (int i = 0; i < extensionList.Length; i++) { extensionList[i] = extensionList[i].Trim(); } // Validate language names, language names must have length and extensions must start with a period. foreach (string language in languageList) { if (language.Length == 0) { throw new ConfigurationErrorsException(SR.GetString(SR.Language_Names_Cannot_Be_Empty)); } } foreach (string extension in extensionList) { if (extension.Length == 0 || extension[0] != '.') { throw new ConfigurationErrorsException(SR.GetString(SR.Extension_Names_Cannot_Be_Empty_Or_Non_Period_Based)); } } compilerInfo._compilerLanguages = languageList; compilerInfo._compilerExtensions = extensionList; result.AddCompilerInfo(compilerInfo); } // Allow config options to replace redundant compiler entries result.RemoveUnmapped(); }