Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / ErrorsHelper.cs / 1305376 / ErrorsHelper.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Configuration {
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
static internal class ErrorsHelper {
static internal int GetErrorCount(List errors) {
return (errors != null) ? errors.Count : 0;
}
static internal bool GetHasErrors(List errors) {
return GetErrorCount(errors) > 0;
}
static internal void AddError(ref List errors, ConfigurationException e) {
Debug.Assert(e != null, "e != null");
// Create on demand
if (errors == null) {
errors = new List();
}
ConfigurationErrorsException ce = e as ConfigurationErrorsException;
if (ce == null) {
errors.Add(e);
}
else {
ICollection col = ce.ErrorsGeneric;
if (col.Count == 1) {
errors.Add(e);
}
else {
errors.AddRange(col);
}
}
}
static internal void AddErrors(ref List errors, ICollection 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 errors) {
if (errors == null) {
return null;
}
Debug.Assert(errors.Count != 0, "errors.Count != 0");
return new ConfigurationErrorsException(errors);
}
static internal void ThrowOnErrors(List errors) {
ConfigurationErrorsException e = GetErrorsException(errors);
if (e != null) {
throw e;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//-----------------------------------------------------------------------------
namespace System.Configuration {
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
static internal class ErrorsHelper {
static internal int GetErrorCount(List errors) {
return (errors != null) ? errors.Count : 0;
}
static internal bool GetHasErrors(List errors) {
return GetErrorCount(errors) > 0;
}
static internal void AddError(ref List errors, ConfigurationException e) {
Debug.Assert(e != null, "e != null");
// Create on demand
if (errors == null) {
errors = new List();
}
ConfigurationErrorsException ce = e as ConfigurationErrorsException;
if (ce == null) {
errors.Add(e);
}
else {
ICollection col = ce.ErrorsGeneric;
if (col.Count == 1) {
errors.Add(e);
}
else {
errors.AddRange(col);
}
}
}
static internal void AddErrors(ref List errors, ICollection 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 errors) {
if (errors == null) {
return null;
}
Debug.Assert(errors.Count != 0, "errors.Count != 0");
return new ConfigurationErrorsException(errors);
}
static internal void ThrowOnErrors(List errors) {
ConfigurationErrorsException e = GetErrorsException(errors);
if (e != null) {
throw e;
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- EnumerableValidator.cs
- ToolStripItemTextRenderEventArgs.cs
- XmlSchemaImport.cs
- TemplateControlBuildProvider.cs
- ItemCollection.cs
- TypedTableBaseExtensions.cs
- WebUtility.cs
- SafeEventLogWriteHandle.cs
- ToolStripArrowRenderEventArgs.cs
- NetStream.cs
- OrderedDictionaryStateHelper.cs
- VariantWrapper.cs
- PropertyInfoSet.cs
- FontFamilyConverter.cs
- XmlILConstructAnalyzer.cs
- SqlXml.cs
- EntityDataSource.cs
- DescendantOverDescendantQuery.cs
- ActivityExecutorOperation.cs
- URLMembershipCondition.cs
- ForeignConstraint.cs
- DBPropSet.cs
- OutgoingWebRequestContext.cs
- PTProvider.cs
- Helpers.cs
- ServiceReference.cs
- MenuItemAutomationPeer.cs
- DataChangedEventManager.cs
- JoinCqlBlock.cs
- lengthconverter.cs
- ExpandoObject.cs
- WindowsFormsLinkLabel.cs
- SystemFonts.cs
- ObjectIDGenerator.cs
- UriSectionData.cs
- HwndProxyElementProvider.cs
- BinaryParser.cs
- SamlAuthorityBinding.cs
- WriteableBitmap.cs
- ActivityCodeDomSerializationManager.cs
- ProcessThread.cs
- TdsParserStateObject.cs
- SqlCharStream.cs
- TcpProcessProtocolHandler.cs
- BindingSource.cs
- InternalConfigEventArgs.cs
- ExpressionEditor.cs
- OutputCacheProfile.cs
- ProgressBarHighlightConverter.cs
- SqlMethodCallConverter.cs
- OrderedDictionary.cs
- PersonalizableTypeEntry.cs
- ContentAlignmentEditor.cs
- DetailsViewRow.cs
- WebPartUtil.cs
- ObjectDataSourceMethodEventArgs.cs
- Constants.cs
- AnnotationComponentManager.cs
- WindowsRichEdit.cs
- SecurityElement.cs
- RegexTree.cs
- HttpApplication.cs
- Crc32Helper.cs
- SessionIDManager.cs
- NativeActivity.cs
- IdentityHolder.cs
- GenericAuthenticationEventArgs.cs
- ContentFileHelper.cs
- AlternateViewCollection.cs
- ItemList.cs
- FullTrustAssemblyCollection.cs
- TypeInfo.cs
- DebugView.cs
- PersonalizationAdministration.cs
- HyperLinkStyle.cs
- NavigationWindowAutomationPeer.cs
- PersonalizablePropertyEntry.cs
- ByteStack.cs
- TextTreeTextNode.cs
- DependentList.cs
- OutputScopeManager.cs
- VectorAnimationUsingKeyFrames.cs
- ResXBuildProvider.cs
- SiteMapProvider.cs
- MultiAsyncResult.cs
- TabRenderer.cs
- Function.cs
- HtmlMeta.cs
- xdrvalidator.cs
- DesignerObjectListAdapter.cs
- PersistenceTypeAttribute.cs
- DataViewManagerListItemTypeDescriptor.cs
- FileUpload.cs
- Random.cs
- SourceSwitch.cs
- ConsoleCancelEventArgs.cs
- SweepDirectionValidation.cs
- HyperLinkStyle.cs
- StandardBindingOptionalReliableSessionElement.cs
- DSASignatureFormatter.cs