Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Configuration / System / Configuration / ContextInformation.cs / 1305376 / 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
- DoubleLinkList.cs
- ObjectTag.cs
- CustomError.cs
- QuaternionAnimationBase.cs
- AppDomainProtocolHandler.cs
- GridViewEditEventArgs.cs
- ZeroOpNode.cs
- DBPropSet.cs
- MimeMapping.cs
- ClientEndpointLoader.cs
- CorruptStoreException.cs
- TextBoxLine.cs
- PolyBezierSegment.cs
- ArgumentFixer.cs
- ConfigurationLoaderException.cs
- EndOfStreamException.cs
- MaskedTextBoxDesignerActionList.cs
- EventMappingSettingsCollection.cs
- WinEventHandler.cs
- XmlBinaryReader.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- PersonalizationStateInfoCollection.cs
- SerialStream.cs
- GridItemPatternIdentifiers.cs
- ListItemCollection.cs
- SmiSettersStream.cs
- ParserExtension.cs
- TranslateTransform3D.cs
- OleDbPropertySetGuid.cs
- Nodes.cs
- FilteredDataSetHelper.cs
- Transform3D.cs
- StreamGeometry.cs
- ManagedFilter.cs
- SrgsOneOf.cs
- PropertyRecord.cs
- XPathPatternParser.cs
- WebPageTraceListener.cs
- PeekCompletedEventArgs.cs
- SelectionRangeConverter.cs
- LocalFileSettingsProvider.cs
- SystemIPGlobalStatistics.cs
- ToolBarPanel.cs
- LingerOption.cs
- EditorZoneBase.cs
- RuntimeWrappedException.cs
- loginstatus.cs
- EndpointIdentityExtension.cs
- SourceInterpreter.cs
- MemberRelationshipService.cs
- GeneralTransform3DTo2D.cs
- ADMembershipProvider.cs
- VisualStyleElement.cs
- ContextDataSource.cs
- EdmSchemaAttribute.cs
- SpeechEvent.cs
- TextMetrics.cs
- PropertyRef.cs
- CompleteWizardStep.cs
- TransactionContext.cs
- XmlLanguage.cs
- _ServiceNameStore.cs
- AdornerHitTestResult.cs
- DataService.cs
- SkipStoryboardToFill.cs
- FontSource.cs
- RefreshPropertiesAttribute.cs
- DateTimeConstantAttribute.cs
- ZipIOFileItemStream.cs
- InnerItemCollectionView.cs
- ProviderException.cs
- ResXResourceSet.cs
- SoapSchemaMember.cs
- WebResourceUtil.cs
- HtmlLabelAdapter.cs
- XmlNodeChangedEventArgs.cs
- ConfigurationPropertyAttribute.cs
- SamlSecurityToken.cs
- InternalResources.cs
- XmlTextEncoder.cs
- SqlDependency.cs
- CharEntityEncoderFallback.cs
- DomNameTable.cs
- ObjectFullSpanRewriter.cs
- ListBindingHelper.cs
- DefaultAssemblyResolver.cs
- UserControlBuildProvider.cs
- ClientUrlResolverWrapper.cs
- ResourceWriter.cs
- CategoriesDocumentFormatter.cs
- RegexFCD.cs
- HttpApplication.cs
- ChtmlTextWriter.cs
- SingleQueryOperator.cs
- ToolStripSplitButton.cs
- PersonalizationStateInfoCollection.cs
- UserInitiatedRoutedEventPermission.cs
- DataTableClearEvent.cs
- SqlReferenceCollection.cs
- StreamingContext.cs