Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / System / Diagnostics / PresentationTraceSources.cs / 1 / PresentationTraceSources.cs
/****************************************************************************\ * * File: PresentationTraceSources.cs * * This class provides a public interface to access TraceSources for * enabling/disabling/filtering of trace messages by area. * * The other portion of this partial class is generated using * genTraceSource.pl and AvTraceMessages.txt * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System.Collections.Generic; using System.Security; using System.Security.Permissions; using MS.Internal; using System.Windows; namespace System.Diagnostics { ////// PresentationTraceLevel - Enum which describes how much detail to trace about a particular object. /// public enum PresentationTraceLevel { ////// Trace no additional information. /// None, ////// Trace some additional information. /// Low, ////// Trace a medium amount of additional information. /// Medium, ////// Trace all available additional information. /// High, } ////// Helper class for retrieving TraceSources /// public static partial class PresentationTraceSources { //----------------------------------------------------- // // Public Properties // //----------------------------------------------------- ////// DependencyProperty for TraceLevel property. /// public static readonly DependencyProperty TraceLevelProperty = DependencyProperty.RegisterAttached( "TraceLevel", typeof(PresentationTraceLevel), typeof(PresentationTraceSources)); ////// Reads the attached property TraceLevel from the given element. /// public static PresentationTraceLevel GetTraceLevel(object element) { return TraceLevelStore.GetTraceLevel(element); } ////// Writes the attached property TraceLevel to the given element. /// public static void SetTraceLevel(object element, PresentationTraceLevel traceLevel) { TraceLevelStore.SetTraceLevel(element, traceLevel); } //----------------------------------------------------- // // Public Methods // //------------------------------------------------------ ////// Refresh TraceSources (re-read config file), creating if necessary. /// // Note: Better would be to separate enable from the Refresh method. public static void Refresh() { // Let AvTrace know that an explicit Refresh has been called. AvTrace.OnRefresh(); // Re-read the .config files System.Diagnostics.Trace.Refresh(); // Initialize any traces classes if needed if (TraceRefresh != null) { TraceRefresh(); } } internal static event TraceRefreshEventHandler TraceRefresh; ////// Critical: /// 1) Asserts for UMC to set trace level. /// /// TreatAsSafe: /// 1) The code path is only invoked when under a debugger /// if the caller can attach a debugger they already have /// unlimited access to the process. Also the only inputs /// to the assert are simply a label for the name. /// [SecurityCritical, SecurityTreatAsSafe] private static TraceSource CreateTraceSource(string sourceName) { // Create the trace source. Whether or not it will actually // trace anything is a decision of the trace source, e.g. it // depends on the app.config file settings. TraceSource source = new TraceSource(sourceName); // If we're attached to the debugger, ensure that at least // warnings/errors are getting traced. if (source.Switch.Level == SourceLevels.Off && AvTrace.IsDebuggerAttached()) { // we need to assert as PT callers under a debugger can invoke this code path // with out having the needed permission to peform this action new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); // BlessedAssert try { source.Switch.Level = SourceLevels.Warning; } finally { SecurityPermission.RevertAssert(); } } // returning source after reverting the assert to avoid // using exposed elements under the assert return source; } } internal delegate void TraceRefreshEventHandler(); } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /****************************************************************************\ * * File: PresentationTraceSources.cs * * This class provides a public interface to access TraceSources for * enabling/disabling/filtering of trace messages by area. * * The other portion of this partial class is generated using * genTraceSource.pl and AvTraceMessages.txt * * Copyright (C) by Microsoft Corporation. All rights reserved. * \***************************************************************************/ using System.Collections.Generic; using System.Security; using System.Security.Permissions; using MS.Internal; using System.Windows; namespace System.Diagnostics { ////// PresentationTraceLevel - Enum which describes how much detail to trace about a particular object. /// public enum PresentationTraceLevel { ////// Trace no additional information. /// None, ////// Trace some additional information. /// Low, ////// Trace a medium amount of additional information. /// Medium, ////// Trace all available additional information. /// High, } ////// Helper class for retrieving TraceSources /// public static partial class PresentationTraceSources { //----------------------------------------------------- // // Public Properties // //----------------------------------------------------- ////// DependencyProperty for TraceLevel property. /// public static readonly DependencyProperty TraceLevelProperty = DependencyProperty.RegisterAttached( "TraceLevel", typeof(PresentationTraceLevel), typeof(PresentationTraceSources)); ////// Reads the attached property TraceLevel from the given element. /// public static PresentationTraceLevel GetTraceLevel(object element) { return TraceLevelStore.GetTraceLevel(element); } ////// Writes the attached property TraceLevel to the given element. /// public static void SetTraceLevel(object element, PresentationTraceLevel traceLevel) { TraceLevelStore.SetTraceLevel(element, traceLevel); } //----------------------------------------------------- // // Public Methods // //------------------------------------------------------ ////// Refresh TraceSources (re-read config file), creating if necessary. /// // Note: Better would be to separate enable from the Refresh method. public static void Refresh() { // Let AvTrace know that an explicit Refresh has been called. AvTrace.OnRefresh(); // Re-read the .config files System.Diagnostics.Trace.Refresh(); // Initialize any traces classes if needed if (TraceRefresh != null) { TraceRefresh(); } } internal static event TraceRefreshEventHandler TraceRefresh; ////// Critical: /// 1) Asserts for UMC to set trace level. /// /// TreatAsSafe: /// 1) The code path is only invoked when under a debugger /// if the caller can attach a debugger they already have /// unlimited access to the process. Also the only inputs /// to the assert are simply a label for the name. /// [SecurityCritical, SecurityTreatAsSafe] private static TraceSource CreateTraceSource(string sourceName) { // Create the trace source. Whether or not it will actually // trace anything is a decision of the trace source, e.g. it // depends on the app.config file settings. TraceSource source = new TraceSource(sourceName); // If we're attached to the debugger, ensure that at least // warnings/errors are getting traced. if (source.Switch.Level == SourceLevels.Off && AvTrace.IsDebuggerAttached()) { // we need to assert as PT callers under a debugger can invoke this code path // with out having the needed permission to peform this action new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); // BlessedAssert try { source.Switch.Level = SourceLevels.Warning; } finally { SecurityPermission.RevertAssert(); } } // returning source after reverting the assert to avoid // using exposed elements under the assert return source; } } internal delegate void TraceRefreshEventHandler(); } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- PartialList.cs
- QilXmlReader.cs
- OleDbException.cs
- InfoCardClaim.cs
- DummyDataSource.cs
- HttpHeaderCollection.cs
- CodeTypeParameter.cs
- MethodSignatureGenerator.cs
- WindowsRebar.cs
- ObjectHandle.cs
- oledbmetadatacollectionnames.cs
- DocumentsTrace.cs
- Duration.cs
- SHA1Managed.cs
- Drawing.cs
- Drawing.cs
- SqlFormatter.cs
- streamingZipPartStream.cs
- Baml2006KnownTypes.cs
- Int32EqualityComparer.cs
- VisualBrush.cs
- ContentFileHelper.cs
- TextContainerHelper.cs
- KnownTypesProvider.cs
- TextRunCache.cs
- XmlArrayAttribute.cs
- OdbcCommandBuilder.cs
- DataServiceProcessingPipelineEventArgs.cs
- LeftCellWrapper.cs
- TextParagraphProperties.cs
- ObjectItemConventionAssemblyLoader.cs
- MasterPageParser.cs
- SecurityManager.cs
- UserControlParser.cs
- CfgSemanticTag.cs
- DataControlFieldCollection.cs
- FixedSOMContainer.cs
- DesigntimeLicenseContext.cs
- DocumentOrderQuery.cs
- XmlText.cs
- Rect.cs
- TableItemPattern.cs
- ListManagerBindingsCollection.cs
- ConsoleKeyInfo.cs
- AttachedProperty.cs
- processwaithandle.cs
- CaseInsensitiveHashCodeProvider.cs
- ButtonFlatAdapter.cs
- SerializationFieldInfo.cs
- OleDbEnumerator.cs
- WaveHeader.cs
- OpenTypeMethods.cs
- ClientRuntimeConfig.cs
- AnyReturnReader.cs
- TextContainerChangeEventArgs.cs
- OletxTransactionFormatter.cs
- DataGridViewCellPaintingEventArgs.cs
- XmlCustomFormatter.cs
- ZipFileInfoCollection.cs
- MatrixConverter.cs
- HwndTarget.cs
- ManifestResourceInfo.cs
- BezierSegment.cs
- ServiceContractGenerationContext.cs
- MessageQueuePermissionEntryCollection.cs
- ActiveXMessageFormatter.cs
- ColumnClickEvent.cs
- CodeAccessSecurityEngine.cs
- QilName.cs
- FtpRequestCacheValidator.cs
- XPathBuilder.cs
- EntityViewGenerator.cs
- BrowserCapabilitiesFactory35.cs
- KoreanCalendar.cs
- RelationshipManager.cs
- AtomContentProperty.cs
- AggregateException.cs
- ElapsedEventArgs.cs
- _OSSOCK.cs
- WebControlAdapter.cs
- FusionWrap.cs
- XhtmlMobileTextWriter.cs
- WebPartAddingEventArgs.cs
- LineBreak.cs
- WeakKeyDictionary.cs
- ExpressionBuilder.cs
- DnsEndPoint.cs
- ObjectParameter.cs
- WindowsListViewScroll.cs
- DataGridViewTopLeftHeaderCell.cs
- MetadataResolver.cs
- ObfuscationAttribute.cs
- ChannelSinkStacks.cs
- PictureBoxDesigner.cs
- SessionStateContainer.cs
- PreviewKeyDownEventArgs.cs
- GradientStop.cs
- EventHandlerList.cs
- AutomationIdentifierGuids.cs
- EpmCustomContentSerializer.cs