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 / 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
- ProtocolViolationException.cs
- TemplateKey.cs
- Pkcs7Signer.cs
- TextContainerChangeEventArgs.cs
- GatewayIPAddressInformationCollection.cs
- ScrollProperties.cs
- WebPartDisplayModeCancelEventArgs.cs
- WorkflowElementDialog.cs
- SelectionRangeConverter.cs
- SubclassTypeValidator.cs
- Parser.cs
- PlanCompiler.cs
- UnknownBitmapDecoder.cs
- TableAdapterManagerNameHandler.cs
- SelectedDatesCollection.cs
- _DigestClient.cs
- WebPartConnectionsDisconnectVerb.cs
- AdornerPresentationContext.cs
- ServiceModelEnumValidator.cs
- SiteMapHierarchicalDataSourceView.cs
- FieldBuilder.cs
- Rect3DValueSerializer.cs
- SortExpressionBuilder.cs
- SelectedGridItemChangedEvent.cs
- ParserContext.cs
- dbdatarecord.cs
- Security.cs
- InfoCardSymmetricAlgorithm.cs
- ImageBrush.cs
- DynamicMethod.cs
- CommonObjectSecurity.cs
- SimplePropertyEntry.cs
- tibetanshape.cs
- PermissionSet.cs
- DataBoundControlAdapter.cs
- ConfigurationLoaderException.cs
- HelpProvider.cs
- WebPartMenuStyle.cs
- SiteMapNodeItemEventArgs.cs
- DispatcherHooks.cs
- SimpleModelProvider.cs
- DriveInfo.cs
- StylusPointPropertyInfoDefaults.cs
- RadioButtonFlatAdapter.cs
- InstalledFontCollection.cs
- IndependentAnimationStorage.cs
- NextPreviousPagerField.cs
- login.cs
- MobileControlsSectionHandler.cs
- WindowsRebar.cs
- HttpConfigurationContext.cs
- AssemblyAttributes.cs
- TextStore.cs
- InvariantComparer.cs
- DataStreams.cs
- XmlSiteMapProvider.cs
- SqlWebEventProvider.cs
- BoolExpression.cs
- TitleStyle.cs
- TdsParserStaticMethods.cs
- CodeTypeReference.cs
- TrackingDataItem.cs
- UpDownBase.cs
- XmlStreamNodeWriter.cs
- SqlColumnizer.cs
- XmlAttributeOverrides.cs
- NavigatorInput.cs
- MetadataCache.cs
- MailAddress.cs
- DateTimePicker.cs
- BulletedList.cs
- StreamSecurityUpgradeInitiatorBase.cs
- HttpTransportSecurity.cs
- Window.cs
- ScriptingProfileServiceSection.cs
- MergePropertyDescriptor.cs
- UiaCoreApi.cs
- DataBoundControlAdapter.cs
- HtmlToClrEventProxy.cs
- EdgeProfileValidation.cs
- Baml2006SchemaContext.cs
- PerformanceCounterNameAttribute.cs
- WindowsFormsHostAutomationPeer.cs
- FontCacheLogic.cs
- RangeValuePattern.cs
- Token.cs
- SqlErrorCollection.cs
- Instrumentation.cs
- SaveFileDialog.cs
- C14NUtil.cs
- ObjectListItemCollection.cs
- SchemaElement.cs
- NonBatchDirectoryCompiler.cs
- TagElement.cs
- SrgsSemanticInterpretationTag.cs
- Select.cs
- CodeAttributeArgument.cs
- FilterQuery.cs
- BaseDataListDesigner.cs
- DbExpressionBuilder.cs