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
- GradientBrush.cs
- ServiceDurableInstance.cs
- DataKey.cs
- AppModelKnownContentFactory.cs
- LineBreakRecord.cs
- DataGridTextBox.cs
- _HeaderInfo.cs
- ComboBox.cs
- XPathNodePointer.cs
- CodeValidator.cs
- OrderingExpression.cs
- ErrorWrapper.cs
- Wizard.cs
- XmlSchemas.cs
- ContextMenu.cs
- FamilyMapCollection.cs
- XsdBuilder.cs
- CompletionCallbackWrapper.cs
- TextLineBreak.cs
- ValidatingPropertiesEventArgs.cs
- LZCodec.cs
- ChannelFactory.cs
- StyleHelper.cs
- TextDecorationUnitValidation.cs
- InputBuffer.cs
- CodeBinaryOperatorExpression.cs
- ColorTransform.cs
- ImageAutomationPeer.cs
- ResourceReferenceExpression.cs
- ValueTypeFixupInfo.cs
- WebRequestModuleElement.cs
- RelationshipEndMember.cs
- ErrorFormatterPage.cs
- EventKeyword.cs
- Win32.cs
- StylusTip.cs
- SymLanguageVendor.cs
- HtmlInputButton.cs
- objectquery_tresulttype.cs
- Bookmark.cs
- DoubleCollectionConverter.cs
- EDesignUtil.cs
- WindowsAltTab.cs
- ChangePassword.cs
- EntityDataSource.cs
- MobileTextWriter.cs
- SpecialNameAttribute.cs
- XmlSchemaValidator.cs
- DeflateEmulationStream.cs
- Drawing.cs
- HandledEventArgs.cs
- TypeLoadException.cs
- FrameworkTextComposition.cs
- IndentedWriter.cs
- EventData.cs
- PriorityRange.cs
- DispatcherSynchronizationContext.cs
- ResponseBodyWriter.cs
- SystemIcmpV4Statistics.cs
- DataGridViewTextBoxColumn.cs
- ProcessManager.cs
- TextTrailingWordEllipsis.cs
- localization.cs
- FullTrustAssemblyCollection.cs
- SqlMethodAttribute.cs
- SecurityToken.cs
- PeerOutputChannel.cs
- GridSplitterAutomationPeer.cs
- PickDesigner.xaml.cs
- OdbcConnectionPoolProviderInfo.cs
- DataSourceConverter.cs
- OledbConnectionStringbuilder.cs
- PointF.cs
- Msec.cs
- SecurityAlgorithmSuite.cs
- GetPageCompletedEventArgs.cs
- XpsS0ValidatingLoader.cs
- SharedUtils.cs
- WindowsFormsHelpers.cs
- ScriptingAuthenticationServiceSection.cs
- ReflectionUtil.cs
- EmbeddedObject.cs
- TransformerTypeCollection.cs
- X509ServiceCertificateAuthenticationElement.cs
- RequestTimeoutManager.cs
- PackagePartCollection.cs
- WebEventCodes.cs
- CompositeScriptReferenceEventArgs.cs
- GeneralTransform3D.cs
- BigInt.cs
- OneOfScalarConst.cs
- InputProcessorProfilesLoader.cs
- EngineSiteSapi.cs
- AssemblyFilter.cs
- SQLBoolean.cs
- ExtentCqlBlock.cs
- SubstitutionList.cs
- XdrBuilder.cs
- RegexGroup.cs
- AlternateViewCollection.cs