Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / Diagnostics / PresentationTraceSources.cs / 1305600 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- WorkflowDesignerMessageFilter.cs
- SessionKeyExpiredException.cs
- MarkedHighlightComponent.cs
- SafeCertificateStore.cs
- SqlFactory.cs
- ProfileGroupSettings.cs
- MessageQueueConverter.cs
- DesignTimeTemplateParser.cs
- DataGridBoolColumn.cs
- FigureParagraph.cs
- ComponentCodeDomSerializer.cs
- ObjectSet.cs
- OleDbConnectionInternal.cs
- DataGridViewCellFormattingEventArgs.cs
- XmlChildNodes.cs
- Attributes.cs
- ListInitExpression.cs
- TitleStyle.cs
- ZipPackagePart.cs
- CodeTypeDelegate.cs
- SchemaMapping.cs
- ReflectionUtil.cs
- IntSecurity.cs
- CellCreator.cs
- DecoratedNameAttribute.cs
- SafePEFileHandle.cs
- SqlClientFactory.cs
- DataContractSerializerElement.cs
- ItemChangedEventArgs.cs
- BrowserCapabilitiesFactory.cs
- HttpCookie.cs
- ManagementQuery.cs
- XmlAttribute.cs
- ObjectSet.cs
- Attributes.cs
- CircleHotSpot.cs
- ValidationPropertyAttribute.cs
- ArcSegment.cs
- GroupBox.cs
- BuildProvider.cs
- DbCommandTree.cs
- VBIdentifierTrimConverter.cs
- DbProviderFactory.cs
- TableLayoutColumnStyleCollection.cs
- ToggleButtonAutomationPeer.cs
- SegmentInfo.cs
- Symbol.cs
- WebServiceClientProxyGenerator.cs
- BitmapMetadata.cs
- MatrixCamera.cs
- UnaryNode.cs
- DesignRelationCollection.cs
- MemberRelationshipService.cs
- Win32MouseDevice.cs
- XhtmlConformanceSection.cs
- TypeDescriptor.cs
- ResourcesGenerator.cs
- MaskDesignerDialog.cs
- ObjectListGeneralPage.cs
- DataError.cs
- DoubleIndependentAnimationStorage.cs
- Dump.cs
- ConfigurationHandlersInstallComponent.cs
- HealthMonitoringSection.cs
- XPathNodeInfoAtom.cs
- MarkupCompiler.cs
- ChannelHandler.cs
- StaticFileHandler.cs
- Fx.cs
- GlobalizationSection.cs
- TCPClient.cs
- KeyFrames.cs
- AsyncCompletedEventArgs.cs
- DocumentXmlWriter.cs
- WebPartCatalogCloseVerb.cs
- Console.cs
- Interlocked.cs
- ResourceReferenceKeyNotFoundException.cs
- NativeCppClassAttribute.cs
- DataBoundControlAdapter.cs
- TemplatedMailWebEventProvider.cs
- Blend.cs
- XmlDataCollection.cs
- UnorderedHashRepartitionStream.cs
- TypeNameConverter.cs
- DiagnosticTraceSchemas.cs
- PolyBezierSegment.cs
- infer.cs
- MatrixAnimationBase.cs
- TransformerInfoCollection.cs
- RecommendedAsConfigurableAttribute.cs
- FrameworkObject.cs
- WsdlWriter.cs
- FileStream.cs
- OleDbCommandBuilder.cs
- Int64Animation.cs
- BaseParaClient.cs
- CommonDialog.cs
- SmiEventSink_Default.cs
- Typeface.cs