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
- HttpGetProtocolImporter.cs
- MainMenu.cs
- KeyInfo.cs
- BufferedGenericXmlSecurityToken.cs
- Delegate.cs
- NumberFunctions.cs
- RemoteArgument.cs
- FileUpload.cs
- LicenseManager.cs
- SoapObjectInfo.cs
- RadioButtonStandardAdapter.cs
- odbcmetadatafactory.cs
- EmptyControlCollection.cs
- AssemblyEvidenceFactory.cs
- ValueChangedEventManager.cs
- HyperLinkStyle.cs
- Vars.cs
- UnionExpr.cs
- OpenFileDialog.cs
- ToolStripPanelRenderEventArgs.cs
- MenuItemStyle.cs
- TdsEnums.cs
- nulltextcontainer.cs
- ScrollChangedEventArgs.cs
- TextDecorationCollection.cs
- BinaryMethodMessage.cs
- TextEditor.cs
- DataGridViewRowEventArgs.cs
- DesigntimeLicenseContext.cs
- BufferedOutputStream.cs
- XMLSyntaxException.cs
- StringReader.cs
- MetadataItemEmitter.cs
- QuaternionAnimation.cs
- WebEncodingValidator.cs
- PrintSystemException.cs
- EntityCollectionChangedParams.cs
- ListViewUpdateEventArgs.cs
- TextEmbeddedObject.cs
- AppDomainManager.cs
- KeyboardNavigation.cs
- ComponentResourceManager.cs
- RectangleF.cs
- DoWhile.cs
- VisualBrush.cs
- CopyOfAction.cs
- Process.cs
- ZipIOCentralDirectoryFileHeader.cs
- MsmqIntegrationReceiveParameters.cs
- GridViewCellAutomationPeer.cs
- Int64Animation.cs
- RuntimeConfigLKG.cs
- BitmapMetadataEnumerator.cs
- TrustLevel.cs
- ProviderConnectionPoint.cs
- GenericWebPart.cs
- InputLangChangeEvent.cs
- QueryNode.cs
- CurrencyWrapper.cs
- CssTextWriter.cs
- XmlComplianceUtil.cs
- OrderedDictionaryStateHelper.cs
- AppSettingsSection.cs
- PrePostDescendentsWalker.cs
- JoinCqlBlock.cs
- ElementHost.cs
- codemethodreferenceexpression.cs
- VisualTreeHelper.cs
- SHA512Managed.cs
- StylusPointDescription.cs
- CodeTypeReference.cs
- SourceSwitch.cs
- ParallelEnumerable.cs
- BaseProcessProtocolHandler.cs
- XsltInput.cs
- PublisherMembershipCondition.cs
- MsmqTransportBindingElement.cs
- SimpleTextLine.cs
- InputChannelAcceptor.cs
- JsonCollectionDataContract.cs
- PropertyGridView.cs
- Base64Decoder.cs
- DbProviderConfigurationHandler.cs
- MissingMethodException.cs
- FileNotFoundException.cs
- MembershipValidatePasswordEventArgs.cs
- MouseButtonEventArgs.cs
- XmlNullResolver.cs
- CompletedAsyncResult.cs
- BitmapImage.cs
- TabItem.cs
- KeyValueConfigurationElement.cs
- GridViewColumnCollectionChangedEventArgs.cs
- RelAssertionDirectKeyIdentifierClause.cs
- EventTask.cs
- WpfSharedXamlSchemaContext.cs
- EditingCommands.cs
- Identity.cs
- SecurityContext.cs
- BatchServiceHost.cs