Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WCF / SMDiagnostics / System / ServiceModel / Diagnostics / PiiTraceSource.cs / 1305376 / PiiTraceSource.cs
//------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------- namespace System.ServiceModel.Diagnostics { using System.Configuration; // using System.ServiceModel.Channels; using System.Diagnostics; using System.ServiceModel.Configuration; class PiiTraceSource : TraceSource { string eventSourceName = String.Empty; internal const string LogPii = "logKnownPii"; bool shouldLogPii = false; bool initialized = false; object localSyncObject = new object(); internal PiiTraceSource(string name, string eventSourceName) : base(name) { #pragma warning disable 618 AssertUtility.DebugAssert(!String.IsNullOrEmpty(eventSourceName), "Event log source name must be valid"); #pragma warning restore 618 this.eventSourceName = eventSourceName; } internal PiiTraceSource(string name, string eventSourceName, SourceLevels levels) : base(name, levels) { #pragma warning disable 618 AssertUtility.DebugAssert(!String.IsNullOrEmpty(eventSourceName), "Event log source name must be valid"); #pragma warning restore 618 this.eventSourceName = eventSourceName; } void Initialize() { if (!this.initialized) { lock (localSyncObject) { if (!this.initialized) { string attributeValue = this.Attributes[PiiTraceSource.LogPii]; bool shouldLogPii = false; if (!string.IsNullOrEmpty(attributeValue)) { if (!bool.TryParse(attributeValue, out shouldLogPii)) { shouldLogPii = false; } } if (shouldLogPii) { #pragma warning disable 618 EventLogger logger = new EventLogger(this.eventSourceName, null); #pragma warning restore 618 if (MachineSettingsSection.EnableLoggingKnownPii) { logger.LogEvent(TraceEventType.Information, EventLogCategory.MessageLogging, EventLogEventId.PiiLoggingOn, false); this.shouldLogPii = true; } else { logger.LogEvent(TraceEventType.Error, EventLogCategory.MessageLogging, EventLogEventId.PiiLoggingNotAllowed, false); } } this.initialized = true; } } } } protected override string[] GetSupportedAttributes() { return new string[] { PiiTraceSource.LogPii }; } internal bool ShouldLogPii { get { // ShouldLogPii is called very frequently, don't call Initialize unless we have to. if (!this.initialized) { Initialize(); } return this.shouldLogPii; } set { // If you call this, you know what you're doing this.initialized = true; this.shouldLogPii = value; } } } } // 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
- DynamicQueryableWrapper.cs
- ContextQuery.cs
- ConfigurationManagerHelperFactory.cs
- RelationshipDetailsRow.cs
- PropertyChangingEventArgs.cs
- JobDuplex.cs
- QilCloneVisitor.cs
- ConfigurationValues.cs
- InertiaRotationBehavior.cs
- StorageSetMapping.cs
- Content.cs
- ProxyAttribute.cs
- LinearKeyFrames.cs
- PerfService.cs
- RegexRunnerFactory.cs
- ComponentEditorPage.cs
- TextElementEnumerator.cs
- XmlArrayAttribute.cs
- WindowsPrincipal.cs
- ContainsRowNumberChecker.cs
- Decoder.cs
- GridViewRowPresenter.cs
- TextFragmentEngine.cs
- ZipIOExtraFieldElement.cs
- SingleObjectCollection.cs
- TextTreeNode.cs
- M3DUtil.cs
- TextEffectResolver.cs
- SequentialOutput.cs
- DataColumnChangeEvent.cs
- RealizationContext.cs
- FileDialog.cs
- WebBrowserContainer.cs
- TypeExtension.cs
- XmlSecureResolver.cs
- TdsParserStateObject.cs
- FixedHyperLink.cs
- Lease.cs
- ChannelManager.cs
- FunctionUpdateCommand.cs
- CustomTrackingQuery.cs
- SelectorAutomationPeer.cs
- LogWriteRestartAreaAsyncResult.cs
- PointAnimation.cs
- DynamicResourceExtension.cs
- StringInfo.cs
- DbConnectionFactory.cs
- _ListenerAsyncResult.cs
- RbTree.cs
- Pointer.cs
- NameTable.cs
- ServiceOperationParameter.cs
- PathStreamGeometryContext.cs
- GridViewItemAutomationPeer.cs
- SignatureToken.cs
- ReflectPropertyDescriptor.cs
- OleAutBinder.cs
- AppDomainUnloadedException.cs
- XdrBuilder.cs
- WindowsStatic.cs
- HttpValueCollection.cs
- ScriptDescriptor.cs
- RowTypePropertyElement.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ControlIdConverter.cs
- CssClassPropertyAttribute.cs
- X509CertificateCollection.cs
- ApplicationDirectory.cs
- WebPartConnectionsCancelVerb.cs
- IssuerInformation.cs
- CompensatableTransactionScopeActivityDesigner.cs
- DataBoundControlHelper.cs
- BamlLocalizableResource.cs
- LocalizationParserHooks.cs
- InternalConfigEventArgs.cs
- TransactedBatchContext.cs
- StdValidatorsAndConverters.cs
- formatter.cs
- WFItemsToSpacerVisibility.cs
- SQLStringStorage.cs
- FontNameConverter.cs
- HttpException.cs
- DesignParameter.cs
- NetDataContractSerializer.cs
- regiisutil.cs
- ServicePoint.cs
- NetSectionGroup.cs
- MessageQueueTransaction.cs
- IntSecurity.cs
- BooleanStorage.cs
- CheckedPointers.cs
- EventArgs.cs
- SmiMetaData.cs
- HtmlShimManager.cs
- LineSegment.cs
- ExtensibleClassFactory.cs
- EntityCommandCompilationException.cs
- VersionPair.cs
- ConfigurationSectionHelper.cs
- Calendar.cs