本文整理汇总了C#中System.Configuration.FactoryRecord.AddErrors方法的典型用法代码示例。如果您正苦于以下问题:C# FactoryRecord.AddErrors方法的具体用法?C# FactoryRecord.AddErrors怎么用?C# FactoryRecord.AddErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Configuration.FactoryRecord
的用法示例。
在下文中一共展示了FactoryRecord.AddErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScanSectionsRecursive
private void ScanSectionsRecursive(
XmlUtil xmlUtil, string parentConfigKey, bool inLocation, string locationSubPath,
bool lockChildren, bool skipInChildApps) {
// discard any accumulated local errors
xmlUtil.SchemaErrors.ResetLocalErrors();
int depth;
// only move to child nodes when not on first level (we've already passed the first <configsections>)
if (parentConfigKey.Length == 0 && !inLocation) {
depth = 0;
}
else {
depth = xmlUtil.Reader.Depth;
xmlUtil.StrictReadToNextElement(ExceptionAction.NonSpecific);
}
while (xmlUtil.Reader.Depth == depth + 1) {
string tagName = xmlUtil.Reader.Name;
//
// Check for reserved elements before looking up the factory,
// which may have the same name if it is in error.
//
if (tagName == KEYWORD_CONFIGSECTIONS) {
// Error: duplicate <configSections> tag, or <configSections> not the first tag under <configuration>
xmlUtil.SchemaErrors.AddError(
new ConfigurationErrorsException(SR.GetString(SR.Config_client_config_too_many_configsections_elements, tagName), xmlUtil),
ExceptionAction.NonSpecific);
xmlUtil.StrictSkipToNextElement(ExceptionAction.NonSpecific);
continue;
}
if (tagName == KEYWORD_LOCATION) {
if (parentConfigKey.Length > 0 || inLocation) {
// Error: <location> section not at top level
xmlUtil.SchemaErrors.AddError(
new ConfigurationErrorsException(SR.GetString(SR.Config_location_location_not_allowed), xmlUtil),
ExceptionAction.Global);
xmlUtil.StrictSkipToNextElement(ExceptionAction.NonSpecific);
}
else {
// Recurse into the location section
ScanLocationSection(xmlUtil);
}
continue;
}
string configKey = CombineConfigKey(parentConfigKey, tagName);
FactoryRecord factoryRecord = FindFactoryRecord(configKey, true);
if (factoryRecord == null) {
//
//
if (!ClassFlags[ClassIgnoreLocalErrors]) {
xmlUtil.SchemaErrors.AddError(
new ConfigurationErrorsException(SR.GetString(SR.Config_unrecognized_configuration_section, configKey), xmlUtil),
ExceptionAction.Local);
}
VerifySectionName(tagName, xmlUtil, ExceptionAction.Local, false);
factoryRecord = new FactoryRecord(
configKey,
parentConfigKey,
tagName,
typeof(DefaultSection).AssemblyQualifiedName,
true, // allowLocation
ConfigurationAllowDefinition.Everywhere,
ConfigurationAllowExeDefinition.MachineToRoamingUser,
true, // restartOnExternalChanges
true, // requirePermission
_flags[IsTrusted],
true, // isUndeclared
null,
-1);
// Add any errors we may have encountered to the factory record,
// so that child config that also refer to this unrecognized section
// get the error.
factoryRecord.AddErrors(xmlUtil.SchemaErrors.RetrieveAndResetLocalErrors(true));
// Add the factory to the list of factories
EnsureFactories()[configKey] = factoryRecord;
}
if (factoryRecord.IsGroup) {
//
// Section Group
//
if (factoryRecord.HasErrors) {
xmlUtil.StrictSkipToNextElement(ExceptionAction.NonSpecific);
}
else {
//.........这里部分代码省略.........