Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / Configuration / System / Configuration / ConfigurationSchemaErrors.cs / 1 / ConfigurationSchemaErrors.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Configuration { using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; internal class ConfigurationSchemaErrors { // Errors with ExceptionAction.Local are logged to this list. // This list is reset when processing of a section is complete. // Errors on this list may be added to the _errorsAll list // when RetrieveAndResetLocalErrors is called. private List_errorsLocal; // Errors with ExceptionAction.Global are logged to this list. private List _errorsGlobal; // All errors related to a config file are logged to this list. // This includes all global errors, all non-specific errors, // and local errors for input that applies to this config file. private List _errorsAll; internal ConfigurationSchemaErrors() {} internal bool HasLocalErrors { get { return ErrorsHelper.GetHasErrors(_errorsLocal); } } internal bool HasGlobalErrors { get { return ErrorsHelper.GetHasErrors(_errorsGlobal); } } private bool HasAllErrors { get { return ErrorsHelper.GetHasErrors(_errorsAll); } } internal int GlobalErrorCount { get { return ErrorsHelper.GetErrorCount(_errorsGlobal); } } // // Add a configuration Error. // internal void AddError(ConfigurationException ce, ExceptionAction action) { switch (action) { case ExceptionAction.Global: ErrorsHelper.AddError(ref _errorsAll, ce); ErrorsHelper.AddError(ref _errorsGlobal, ce); break; case ExceptionAction.NonSpecific: ErrorsHelper.AddError(ref _errorsAll, ce); break; case ExceptionAction.Local: ErrorsHelper.AddError(ref _errorsLocal, ce); break; } } internal void SetSingleGlobalError(ConfigurationException ce) { _errorsAll = null; _errorsLocal = null; _errorsGlobal = null; AddError(ce, ExceptionAction.Global); } internal bool HasErrors(bool ignoreLocal) { if (ignoreLocal) { return HasGlobalErrors; } else { return HasAllErrors; } } // ThrowIfErrors // // Throw if Errors were detected and remembered. // // Parameters: // IgnoreLocal - Should we be using the local errors also to // detemine if we should throw? // // Note: We will always return all the errors, no matter what // IgnoreLocal is. // internal void ThrowIfErrors(bool ignoreLocal) { if (HasErrors(ignoreLocal)) { if (HasGlobalErrors) { // Throw just the global errors, as they invalidate // all other config file parsing. throw new ConfigurationErrorsException(_errorsGlobal); } else { // Throw all errors no matter what throw new ConfigurationErrorsException(_errorsAll); } } } // RetrieveAndResetLocalErrors // // Retrieve the Local Errors, and Reset them to none. // internal List RetrieveAndResetLocalErrors(bool keepLocalErrors) { List list = _errorsLocal; _errorsLocal = null; if (keepLocalErrors) { ErrorsHelper.AddErrors(ref _errorsAll, list); } return list; } // // Add errors that have been saved for a specific section. // internal void AddSavedLocalErrors(ICollection coll) { ErrorsHelper.AddErrors(ref _errorsAll, coll); } // ResetLocalErrors // // Remove all the Local Errors, so we can start from scratch // internal void ResetLocalErrors() { RetrieveAndResetLocalErrors(false); } } } // 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.Generic; using System.Collections.Specialized; using System.Text; internal class ConfigurationSchemaErrors { // Errors with ExceptionAction.Local are logged to this list. // This list is reset when processing of a section is complete. // Errors on this list may be added to the _errorsAll list // when RetrieveAndResetLocalErrors is called. private List_errorsLocal; // Errors with ExceptionAction.Global are logged to this list. private List _errorsGlobal; // All errors related to a config file are logged to this list. // This includes all global errors, all non-specific errors, // and local errors for input that applies to this config file. private List _errorsAll; internal ConfigurationSchemaErrors() {} internal bool HasLocalErrors { get { return ErrorsHelper.GetHasErrors(_errorsLocal); } } internal bool HasGlobalErrors { get { return ErrorsHelper.GetHasErrors(_errorsGlobal); } } private bool HasAllErrors { get { return ErrorsHelper.GetHasErrors(_errorsAll); } } internal int GlobalErrorCount { get { return ErrorsHelper.GetErrorCount(_errorsGlobal); } } // // Add a configuration Error. // internal void AddError(ConfigurationException ce, ExceptionAction action) { switch (action) { case ExceptionAction.Global: ErrorsHelper.AddError(ref _errorsAll, ce); ErrorsHelper.AddError(ref _errorsGlobal, ce); break; case ExceptionAction.NonSpecific: ErrorsHelper.AddError(ref _errorsAll, ce); break; case ExceptionAction.Local: ErrorsHelper.AddError(ref _errorsLocal, ce); break; } } internal void SetSingleGlobalError(ConfigurationException ce) { _errorsAll = null; _errorsLocal = null; _errorsGlobal = null; AddError(ce, ExceptionAction.Global); } internal bool HasErrors(bool ignoreLocal) { if (ignoreLocal) { return HasGlobalErrors; } else { return HasAllErrors; } } // ThrowIfErrors // // Throw if Errors were detected and remembered. // // Parameters: // IgnoreLocal - Should we be using the local errors also to // detemine if we should throw? // // Note: We will always return all the errors, no matter what // IgnoreLocal is. // internal void ThrowIfErrors(bool ignoreLocal) { if (HasErrors(ignoreLocal)) { if (HasGlobalErrors) { // Throw just the global errors, as they invalidate // all other config file parsing. throw new ConfigurationErrorsException(_errorsGlobal); } else { // Throw all errors no matter what throw new ConfigurationErrorsException(_errorsAll); } } } // RetrieveAndResetLocalErrors // // Retrieve the Local Errors, and Reset them to none. // internal List RetrieveAndResetLocalErrors(bool keepLocalErrors) { List list = _errorsLocal; _errorsLocal = null; if (keepLocalErrors) { ErrorsHelper.AddErrors(ref _errorsAll, list); } return list; } // // Add errors that have been saved for a specific section. // internal void AddSavedLocalErrors(ICollection coll) { ErrorsHelper.AddErrors(ref _errorsAll, coll); } // ResetLocalErrors // // Remove all the Local Errors, so we can start from scratch // internal void ResetLocalErrors() { RetrieveAndResetLocalErrors(false); } } } // 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
- WindowsUpDown.cs
- KeyPressEvent.cs
- Symbol.cs
- ClientSection.cs
- StickyNoteAnnotations.cs
- ButtonPopupAdapter.cs
- HtmlImageAdapter.cs
- DbTransaction.cs
- TextDocumentView.cs
- Line.cs
- RootBrowserWindowAutomationPeer.cs
- XmlReturnReader.cs
- InheritanceRules.cs
- ApplicationInfo.cs
- RangeValidator.cs
- HtmlCommandAdapter.cs
- Point4DValueSerializer.cs
- FunctionCommandText.cs
- ObjectTag.cs
- TemplatePropertyEntry.cs
- StreamFormatter.cs
- PtsCache.cs
- ManualWorkflowSchedulerService.cs
- ConfigXmlSignificantWhitespace.cs
- InstancePersistenceException.cs
- ResXResourceReader.cs
- DoubleLinkList.cs
- MimeTypePropertyAttribute.cs
- RSACryptoServiceProvider.cs
- HijriCalendar.cs
- HttpModuleAction.cs
- DataGridViewCellConverter.cs
- WebServiceBindingAttribute.cs
- TextClipboardData.cs
- SpellerInterop.cs
- KnownTypesProvider.cs
- Compiler.cs
- ControlCachePolicy.cs
- HyperLink.cs
- PackWebRequestFactory.cs
- XhtmlBasicPageAdapter.cs
- MdbDataFileEditor.cs
- _IPv4Address.cs
- HtmlWindow.cs
- InstanceDataCollection.cs
- StringFormat.cs
- ComponentCollection.cs
- ImageListDesigner.cs
- AlignmentYValidation.cs
- StyleCollection.cs
- SafeNativeMethods.cs
- ObjectDataSourceView.cs
- DynamicActivity.cs
- SynchronizationLockException.cs
- HttpResponseBase.cs
- SvcMapFile.cs
- RSAPKCS1KeyExchangeFormatter.cs
- DefaultValueAttribute.cs
- COM2IDispatchConverter.cs
- AssociationType.cs
- StorageScalarPropertyMapping.cs
- ListBoxAutomationPeer.cs
- UITypeEditor.cs
- PersonalizablePropertyEntry.cs
- WebEventCodes.cs
- SecurityContext.cs
- FileDialog.cs
- PointConverter.cs
- FieldNameLookup.cs
- DataGridViewCellStateChangedEventArgs.cs
- TextEditorCharacters.cs
- CustomTrackingQuery.cs
- AttachedAnnotation.cs
- DodSequenceMerge.cs
- Conditional.cs
- Lease.cs
- UpdateDelegates.Generated.cs
- ObjectView.cs
- ProfileService.cs
- HotSpot.cs
- SingleAnimation.cs
- PolygonHotSpot.cs
- RichTextBoxAutomationPeer.cs
- XmlEncodedRawTextWriter.cs
- XmlNodeChangedEventArgs.cs
- DataViewSetting.cs
- Sql8ConformanceChecker.cs
- DataViewManager.cs
- DataGridHelper.cs
- UpdateRecord.cs
- SpeakInfo.cs
- PathSegment.cs
- ObjectAnimationBase.cs
- WebResourceAttribute.cs
- FixedSOMPage.cs
- ScrollContentPresenter.cs
- TerminateSequence.cs
- SystemPens.cs
- DataSourceBooleanViewSchemaConverter.cs
- TrackingLocation.cs