Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Configuration / System / Configuration / ContextInformation.cs / 1 / ContextInformation.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; namespace System.Configuration { // ContextInformation // // Class that encapsulates all of the Context Information that // is going to be associated with a ConfigurationElement // public sealed class ContextInformation { private bool _hostingContextEvaluated; // Do we know the Context? private object _hostingContext; // HostingContext private BaseConfigurationRecord _configRecord; // Constructor // // internal ContextInformation( BaseConfigurationRecord configRecord ) { Debug.Assert(configRecord != null, "configRecord != null"); _hostingContextEvaluated = false; _hostingContext = null; _configRecord = configRecord; } // HostingContext // // Retrieve the Context of the environment that we are being // evaluated in. (currently this can we WebContext, ExeContext, // or null) // public object HostingContext { get { if ( !_hostingContextEvaluated ) { // Retrieve Context _hostingContext = _configRecord.ConfigContext; _hostingContextEvaluated = true; } return _hostingContext; } } // IsMachineLevel // // Is this the machine.config file or not? If it is not // then use the Hosting Context to determine where you are // and in what hierarchy you are in // public bool IsMachineLevel { get { return _configRecord.IsMachineConfig; } } // GetSection // // Get a Section within the context of where we are. What // ever section you retrieve here will be at the same level // in the hierarchy as we are. // // Note: Watch out for a situation where you request a section // that will call you. // public object GetSection(string sectionName) { return _configRecord.GetSection(sectionName); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; namespace System.Configuration { // ContextInformation // // Class that encapsulates all of the Context Information that // is going to be associated with a ConfigurationElement // public sealed class ContextInformation { private bool _hostingContextEvaluated; // Do we know the Context? private object _hostingContext; // HostingContext private BaseConfigurationRecord _configRecord; // Constructor // // internal ContextInformation( BaseConfigurationRecord configRecord ) { Debug.Assert(configRecord != null, "configRecord != null"); _hostingContextEvaluated = false; _hostingContext = null; _configRecord = configRecord; } // HostingContext // // Retrieve the Context of the environment that we are being // evaluated in. (currently this can we WebContext, ExeContext, // or null) // public object HostingContext { get { if ( !_hostingContextEvaluated ) { // Retrieve Context _hostingContext = _configRecord.ConfigContext; _hostingContextEvaluated = true; } return _hostingContext; } } // IsMachineLevel // // Is this the machine.config file or not? If it is not // then use the Hosting Context to determine where you are // and in what hierarchy you are in // public bool IsMachineLevel { get { return _configRecord.IsMachineConfig; } } // GetSection // // Get a Section within the context of where we are. What // ever section you retrieve here will be at the same level // in the hierarchy as we are. // // Note: Watch out for a situation where you request a section // that will call you. // public object GetSection(string sectionName) { return _configRecord.GetSection(sectionName); } } } // 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
- IndexerNameAttribute.cs
- ConnectionManagementSection.cs
- VisualCollection.cs
- PersonalizationState.cs
- ImageDrawing.cs
- SimpleMailWebEventProvider.cs
- XmlRootAttribute.cs
- RectValueSerializer.cs
- StandardRuntimeEnumValidatorAttribute.cs
- SymLanguageType.cs
- ProfileParameter.cs
- GorillaCodec.cs
- SafeViewOfFileHandle.cs
- PrintPreviewDialog.cs
- XmlSchemaComplexContent.cs
- _SpnDictionary.cs
- ControlBindingsCollection.cs
- AllowedAudienceUriElementCollection.cs
- OdbcCommandBuilder.cs
- BindingList.cs
- FilterElement.cs
- ContextMenuService.cs
- Marshal.cs
- UdpReplyToBehavior.cs
- TextFindEngine.cs
- TdsEnums.cs
- InputReportEventArgs.cs
- XmlnsDictionary.cs
- WindowsSysHeader.cs
- ConsoleKeyInfo.cs
- AsyncOperation.cs
- SQLRoleProvider.cs
- invalidudtexception.cs
- BaseValidator.cs
- ImportStoreException.cs
- GridLengthConverter.cs
- ListItemsCollectionEditor.cs
- SuppressMessageAttribute.cs
- DeflateEmulationStream.cs
- UnauthorizedWebPart.cs
- ListViewGroup.cs
- WindowsPen.cs
- PtsPage.cs
- ReadOnlyHierarchicalDataSource.cs
- SqlClientFactory.cs
- DescendantOverDescendantQuery.cs
- SoapObjectInfo.cs
- StoreContentChangedEventArgs.cs
- WebExceptionStatus.cs
- HttpValueCollection.cs
- Calendar.cs
- FormsIdentity.cs
- SpeechDetectedEventArgs.cs
- PkcsMisc.cs
- Cursors.cs
- PrivateUnsafeNativeCompoundFileMethods.cs
- SmiConnection.cs
- HTMLTextWriter.cs
- KeyTimeConverter.cs
- _AcceptOverlappedAsyncResult.cs
- ClientTargetCollection.cs
- DivideByZeroException.cs
- CounterSet.cs
- OleDbMetaDataFactory.cs
- LineGeometry.cs
- UriSectionReader.cs
- dsa.cs
- Formatter.cs
- FastEncoder.cs
- Pen.cs
- ISAPIApplicationHost.cs
- SelectionChangedEventArgs.cs
- JobStaple.cs
- ContextMenuStrip.cs
- RegisteredHiddenField.cs
- TreeNodeStyleCollectionEditor.cs
- TraceUtility.cs
- GridItemCollection.cs
- TreeViewEvent.cs
- QilInvokeLateBound.cs
- PeerSecurityHelpers.cs
- lengthconverter.cs
- ImageSourceConverter.cs
- Registry.cs
- InteropBitmapSource.cs
- UIPermission.cs
- InkCanvasSelectionAdorner.cs
- UpdatePanelTrigger.cs
- ShapeTypeface.cs
- _AutoWebProxyScriptEngine.cs
- HtmlWindowCollection.cs
- BaseValidator.cs
- DataContractJsonSerializer.cs
- WindowHideOrCloseTracker.cs
- IOThreadScheduler.cs
- DataGridRowEventArgs.cs
- OperationContextScope.cs
- OdbcEnvironmentHandle.cs
- MetadataArtifactLoaderFile.cs
- FrameworkContentElementAutomationPeer.cs