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
- InstanceCollisionException.cs
- BaseAsyncResult.cs
- ProgressBarRenderer.cs
- ErrorHandlerModule.cs
- LocalizationComments.cs
- DataGridViewBand.cs
- ClassData.cs
- BindingWorker.cs
- PeerNearMe.cs
- DataListAutoFormat.cs
- EncoderExceptionFallback.cs
- SortExpressionBuilder.cs
- TemplateBindingExpressionConverter.cs
- ImmutableObjectAttribute.cs
- FlowDocumentReader.cs
- Manipulation.cs
- HttpValueCollection.cs
- InstanceOwnerException.cs
- SoapCodeExporter.cs
- Identifier.cs
- RTLAwareMessageBox.cs
- HistoryEventArgs.cs
- FunctionOverloadResolver.cs
- ParserExtension.cs
- AVElementHelper.cs
- SimpleBitVector32.cs
- TreeNodeConverter.cs
- NamedPermissionSet.cs
- VisualTreeUtils.cs
- Compiler.cs
- QilStrConcatenator.cs
- PolygonHotSpot.cs
- NavigatorOutput.cs
- UserUseLicenseDictionaryLoader.cs
- TextDecoration.cs
- ListSourceHelper.cs
- DiscoveryUtility.cs
- LoginCancelEventArgs.cs
- ResXBuildProvider.cs
- DataSourceDesigner.cs
- DoubleIndependentAnimationStorage.cs
- TextTreeRootNode.cs
- HttpModule.cs
- MessageBox.cs
- WebChannelFactory.cs
- CodeTypeDeclarationCollection.cs
- GenericTypeParameterBuilder.cs
- XPathSelfQuery.cs
- AbandonedMutexException.cs
- TypeCodeDomSerializer.cs
- HttpVersion.cs
- NumberFormatter.cs
- AsymmetricSignatureDeformatter.cs
- ButtonBaseAdapter.cs
- ExtenderControl.cs
- AmbientValueAttribute.cs
- ValidationRule.cs
- Pair.cs
- WebEventTraceProvider.cs
- ScriptControl.cs
- GridViewRowPresenterBase.cs
- CachedCompositeFamily.cs
- TerminateSequenceResponse.cs
- ClockGroup.cs
- Polyline.cs
- SqlResolver.cs
- _SingleItemRequestCache.cs
- ExpressionNode.cs
- LocalizableAttribute.cs
- SqlTransaction.cs
- FillErrorEventArgs.cs
- ThemeableAttribute.cs
- control.ime.cs
- BindingListCollectionView.cs
- MenuItemAutomationPeer.cs
- ControlPropertyNameConverter.cs
- Converter.cs
- Soap12ProtocolImporter.cs
- ProcessProtocolHandler.cs
- FormClosedEvent.cs
- ResourceProperty.cs
- grammarelement.cs
- PriorityQueue.cs
- EventProvider.cs
- baseshape.cs
- MessageBox.cs
- SimpleWorkerRequest.cs
- TextServicesCompartmentEventSink.cs
- EntityDataReader.cs
- XmlNamespaceDeclarationsAttribute.cs
- SqlDataSourceRefreshSchemaForm.cs
- ObjectManager.cs
- XmlSchemaCollection.cs
- SerialReceived.cs
- XamlBrushSerializer.cs
- EventMappingSettings.cs
- PngBitmapDecoder.cs
- WeakRefEnumerator.cs
- Internal.cs
- TopClause.cs