Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / TrustUi / MS / Internal / documents / Application / Trace.cs / 1 / Trace.cs
//------------------------------------------------------------------------------ //// Copyright (C) Microsoft Corporation. All rights reserved. // //// Utility class for Trace switches and methods for XpsViewer. // // // History: // 08/28/2005: [....]: Initial implementation. //----------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Globalization; using System.Security; namespace MS.Internal.Documents.Application { ////// Utility class for Trace switches and methods for XpsViewer. /// internal static class Trace { #region Internal Methods //------------------------------------------------------------------------- // Internal Methods //------------------------------------------------------------------------- /// /// Will permit only internet zone permissions for TraceListeners and is /// safe to use inside of asserts for partial trust code. /// ////// Critical: /// - Used in Assert blocks we must always revert to our lowest permission /// set because registered TraceListners may usurpe our evilvations. /// TreatAsSafe: /// - Marked Critical for audit only that PermitOnly is performed as first /// operation to ensure integrity of other reviews that depended on this /// fact. /// [SecurityCritical, SecurityTreatAsSafe] internal static void SafeWrite( BooleanSwitch boolSwitch, string format, params object[] args) { InternetPermissionSet.PermitOnly(); if (AvTrace.IsWpfTracingEnabledInRegistry()) { System.Diagnostics.Trace.WriteLineIf( boolSwitch.Enabled, string.Format( CultureInfo.CurrentUICulture, format, args), boolSwitch.DisplayName); } CodeAccessPermission.RevertPermitOnly(); } ////// Will permit only internet zone permissions for TraceListeners and is /// safe to use inside of asserts for partial trust code. /// ////// Critical: /// - Used in Assert blocks we must always revert to our lowest permission /// set because registered TraceListeners may usurp our permissions. /// TreatAsSafe: /// - Marked Critical for audit only that PermitOnly is performed as first /// operation to ensure integrity of other reviews that depended on this /// fact. /// [SecurityCritical, SecurityTreatAsSafe] internal static void SafeWriteIf( bool condition, BooleanSwitch boolSwitch, string format, params object[] args) { InternetPermissionSet.PermitOnly(); if (AvTrace.IsWpfTracingEnabledInRegistry()) { System.Diagnostics.Trace.WriteLineIf( boolSwitch.Enabled && condition, string.Format( CultureInfo.CurrentCulture, format, args), boolSwitch.DisplayName); } CodeAccessPermission.RevertPermitOnly(); } #endregion Internal Methods #region Internal Fields //-------------------------------------------------------------------------- // Internal Fields //------------------------------------------------------------------------- internal static BooleanSwitch File = new BooleanSwitch( FileSwitchName, FileSwitchName, "1"); internal static BooleanSwitch Packaging = new BooleanSwitch( PackagingSwitchName, PackagingSwitchName, "1"); internal static BooleanSwitch Presentation = new BooleanSwitch( PresentationSwitchName, PresentationSwitchName, "1"); internal static BooleanSwitch Rights = new BooleanSwitch( RightsSwitchName, RightsSwitchName, "1"); internal static BooleanSwitch Signatures = new BooleanSwitch( SignaturesSwitchName, SignaturesSwitchName, "1"); #endregion Internal Fields #region Private Fields //-------------------------------------------------------------------------- // Private Fields //-------------------------------------------------------------------------- ////// Critical: /// - Used in Assert blocks we must always revert to our lowest permission /// set because registered TraceListeners may usurp our permissions. /// TreatAsSafe: /// - Marked Critical for audit only that PermitOnly is performed as first /// operation to ensure integrity of other reviews that depended on this /// fact. /// [SecurityCritical, SecurityTreatAsSafe] private static readonly NamedPermissionSet InternetPermissionSet = new NamedPermissionSet("Internet"); private const string FileSwitchName = "XpsViewerFile"; private const string PackagingSwitchName = "XpsViewerPackaging"; private const string PresentationSwitchName = "XpsViewerUI"; private const string RightsSwitchName = "XpsViewerRights"; private const string SignaturesSwitchName = "XpsViewerSignatures"; #endregion Private Fields } } // 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
- ExpressionServices.cs
- Attributes.cs
- SerializationObjectManager.cs
- BitmapSourceSafeMILHandle.cs
- KerberosReceiverSecurityToken.cs
- ToolStripStatusLabel.cs
- RenderDataDrawingContext.cs
- TreeViewImageIndexConverter.cs
- XmlBoundElement.cs
- CommonObjectSecurity.cs
- BufferAllocator.cs
- ParameterCollection.cs
- ManagementBaseObject.cs
- InstanceDataCollection.cs
- NamedPipeTransportManager.cs
- DefaultProxySection.cs
- ManualWorkflowSchedulerService.cs
- DataSourceView.cs
- InputLanguageEventArgs.cs
- SyndicationSerializer.cs
- XPathSelfQuery.cs
- DynamicRenderer.cs
- Label.cs
- PreviewPrintController.cs
- PeoplePickerWrapper.cs
- UnsettableComboBox.cs
- Itemizer.cs
- IDQuery.cs
- TransactionsSectionGroup.cs
- InvalidOperationException.cs
- UserControl.cs
- ComponentDispatcher.cs
- SystemDiagnosticsSection.cs
- hebrewshape.cs
- ConfigurationStrings.cs
- MimePart.cs
- EntitySqlQueryState.cs
- AesManaged.cs
- DocumentPaginator.cs
- XmlRootAttribute.cs
- DefaultTextStore.cs
- _AutoWebProxyScriptHelper.cs
- SubMenuStyleCollection.cs
- SmiTypedGetterSetter.cs
- ClientTarget.cs
- SpeechUI.cs
- UnsafeNativeMethods.cs
- ControlHelper.cs
- ISFClipboardData.cs
- WebPart.cs
- OneOfTypeConst.cs
- InputManager.cs
- LinqMaximalSubtreeNominator.cs
- ShaperBuffers.cs
- EnumUnknown.cs
- Typography.cs
- DataSourceDescriptorCollection.cs
- UIElementParaClient.cs
- ActivationProxy.cs
- WindowsListBox.cs
- DetailsViewActionList.cs
- IResourceProvider.cs
- PolicyException.cs
- SystemEvents.cs
- ApplicationDirectoryMembershipCondition.cs
- RelationshipEntry.cs
- Style.cs
- TextLineBreak.cs
- SqlDataSourceConfigureSortForm.cs
- ServicePoint.cs
- TypedColumnHandler.cs
- controlskin.cs
- DocumentViewerAutomationPeer.cs
- Page.cs
- HeaderCollection.cs
- RestHandlerFactory.cs
- DrawingCollection.cs
- AmbientLight.cs
- MetaType.cs
- ReadOnlyDataSourceView.cs
- AuthStoreRoleProvider.cs
- HTMLTextWriter.cs
- SystemDiagnosticsSection.cs
- LinkTarget.cs
- RelOps.cs
- ServiceBehaviorElementCollection.cs
- EDesignUtil.cs
- GlyphTypeface.cs
- Constants.cs
- HtmlAnchor.cs
- XPathExpr.cs
- QueryableDataSourceHelper.cs
- PropertyValidationContext.cs
- ColorDialog.cs
- BamlWriter.cs
- FigureParagraph.cs
- IPipelineRuntime.cs
- MessageQueuePermissionEntryCollection.cs
- FaultConverter.cs
- HandlerBase.cs