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
- GatewayDefinition.cs
- KeyboardNavigation.cs
- Light.cs
- MonitorWrapper.cs
- WebCategoryAttribute.cs
- ProxyFragment.cs
- Point3D.cs
- Misc.cs
- NativeMethodsCLR.cs
- SelectionProcessor.cs
- JulianCalendar.cs
- AndMessageFilter.cs
- UIntPtr.cs
- ActivationServices.cs
- AutomationPeer.cs
- BinaryConverter.cs
- InkCanvas.cs
- StateManagedCollection.cs
- PathHelper.cs
- TemplateBindingExtensionConverter.cs
- XamlToRtfParser.cs
- UnmanagedMarshal.cs
- PinnedBufferMemoryStream.cs
- LambdaCompiler.Address.cs
- AttributeAction.cs
- XamlSerializationHelper.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- JapaneseCalendar.cs
- SqlUnionizer.cs
- SqlEnums.cs
- PaginationProgressEventArgs.cs
- FormatterServicesNoSerializableCheck.cs
- ResXResourceWriter.cs
- Rect3D.cs
- WebPartMenu.cs
- Baml2006KnownTypes.cs
- CharConverter.cs
- OrderByBuilder.cs
- RegistryConfigurationProvider.cs
- HtmlMeta.cs
- CodeRegionDirective.cs
- RowToParametersTransformer.cs
- ValidatorCollection.cs
- httpserverutility.cs
- WebSysDefaultValueAttribute.cs
- TreeWalker.cs
- ColorTransformHelper.cs
- ObjRef.cs
- SelectorAutomationPeer.cs
- PrintDialogException.cs
- SymDocumentType.cs
- XpsException.cs
- Validator.cs
- DelayedRegex.cs
- IChannel.cs
- AddInEnvironment.cs
- QuaternionKeyFrameCollection.cs
- ProjectionPlan.cs
- StrokeNodeOperations.cs
- RequestQueue.cs
- Char.cs
- ValidationEventArgs.cs
- UInt16Converter.cs
- AutomationEventArgs.cs
- mediapermission.cs
- XmlHierarchicalDataSourceView.cs
- SerialErrors.cs
- SudsCommon.cs
- RuntimeHandles.cs
- StateRuntime.cs
- CharacterHit.cs
- SecurityManager.cs
- PreviewPrintController.cs
- DomNameTable.cs
- TableLayoutCellPaintEventArgs.cs
- ParseHttpDate.cs
- PkcsMisc.cs
- AbandonedMutexException.cs
- AuthorizationRuleCollection.cs
- Comparer.cs
- BulletedListEventArgs.cs
- StructuredTypeInfo.cs
- UMPAttributes.cs
- XPathNavigatorKeyComparer.cs
- TypeSemantics.cs
- LicenseManager.cs
- UseAttributeSetsAction.cs
- ClientScriptItem.cs
- DataSourceCacheDurationConverter.cs
- PersonalizationProvider.cs
- AffineTransform3D.cs
- SemaphoreSecurity.cs
- ConsoleCancelEventArgs.cs
- ActivityStatusChangeEventArgs.cs
- TextClipboardData.cs
- TimeoutHelper.cs
- SizeKeyFrameCollection.cs
- SignatureDescription.cs
- CaseInsensitiveHashCodeProvider.cs
- FrugalList.cs