You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
72
external/referencesource/System.Configuration/System/Configuration/ErrorsHelper.cs
vendored
Normal file
72
external/referencesource/System.Configuration/System/Configuration/ErrorsHelper.cs
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <copyright file="FactoryRecord.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace System.Configuration {
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
|
||||
static internal class ErrorsHelper {
|
||||
|
||||
static internal int GetErrorCount(List<ConfigurationException> errors) {
|
||||
return (errors != null) ? errors.Count : 0;
|
||||
}
|
||||
|
||||
static internal bool GetHasErrors(List<ConfigurationException> errors) {
|
||||
return GetErrorCount(errors) > 0;
|
||||
}
|
||||
|
||||
static internal void AddError(ref List<ConfigurationException> errors, ConfigurationException e) {
|
||||
Debug.Assert(e != null, "e != null");
|
||||
|
||||
// Create on demand
|
||||
if (errors == null) {
|
||||
errors = new List<ConfigurationException>();
|
||||
}
|
||||
|
||||
ConfigurationErrorsException ce = e as ConfigurationErrorsException;
|
||||
if (ce == null) {
|
||||
errors.Add(e);
|
||||
}
|
||||
else {
|
||||
ICollection<ConfigurationException> col = ce.ErrorsGeneric;
|
||||
if (col.Count == 1) {
|
||||
errors.Add(e);
|
||||
}
|
||||
else {
|
||||
errors.AddRange(col);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static internal void AddErrors(ref List<ConfigurationException> errors, ICollection<ConfigurationException> coll) {
|
||||
if (coll == null || coll.Count == 0) {
|
||||
// Nothing to do here, bail
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (ConfigurationException e in coll) {
|
||||
AddError(ref errors, e);
|
||||
}
|
||||
}
|
||||
|
||||
static internal ConfigurationErrorsException GetErrorsException(List<ConfigurationException> errors) {
|
||||
if (errors == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Debug.Assert(errors.Count != 0, "errors.Count != 0");
|
||||
return new ConfigurationErrorsException(errors);
|
||||
}
|
||||
|
||||
static internal void ThrowOnErrors(List<ConfigurationException> errors) {
|
||||
ConfigurationErrorsException e = GetErrorsException(errors);
|
||||
if (e != null) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user