Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMDiagnostics / System / ServiceModel / Diagnostics / PiiTraceSource.cs / 1 / 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. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HtmlControl.cs
- TreeNodeClickEventArgs.cs
- OleDbCommandBuilder.cs
- DataStreamFromComStream.cs
- FixedTextView.cs
- COAUTHIDENTITY.cs
- Win32.cs
- EditingCoordinator.cs
- DataControlButton.cs
- BinaryCommonClasses.cs
- FileDetails.cs
- PolicyConversionContext.cs
- LineProperties.cs
- PersonalizationProvider.cs
- FileLogRecordStream.cs
- ConfigurationStrings.cs
- SerTrace.cs
- SmtpAuthenticationManager.cs
- ZipArchive.cs
- ControlAdapter.cs
- GeneralTransformCollection.cs
- Pair.cs
- LayoutEditorPart.cs
- PasswordDeriveBytes.cs
- DynamicResourceExtensionConverter.cs
- TextTreeObjectNode.cs
- Deflater.cs
- SoapAttributes.cs
- StackOverflowException.cs
- ActivityBuilderXamlWriter.cs
- UnmanagedMarshal.cs
- SystemDropShadowChrome.cs
- SliderAutomationPeer.cs
- XmlSerializationGeneratedCode.cs
- SecurityToken.cs
- MergeFailedEvent.cs
- ObjectDesignerDataSourceView.cs
- BitmapEffectDrawingContent.cs
- TraceUtility.cs
- SEHException.cs
- SubtreeProcessor.cs
- AsyncResult.cs
- ColorBlend.cs
- HttpDebugHandler.cs
- Baml6Assembly.cs
- TableItemPattern.cs
- ReadOnlyDataSourceView.cs
- BitmapImage.cs
- SafeFileMappingHandle.cs
- RadioButtonBaseAdapter.cs
- MenuItemStyle.cs
- ServicesUtilities.cs
- BooleanAnimationUsingKeyFrames.cs
- RemoteWebConfigurationHostStream.cs
- TextBoxBase.cs
- XmlSchemaAll.cs
- XmlEntity.cs
- PackagePart.cs
- IPGlobalProperties.cs
- BinaryParser.cs
- DataGridColumnHeader.cs
- ToolStripDropDownClosingEventArgs.cs
- MergeLocalizationDirectives.cs
- CompositionTarget.cs
- ExtendedTransformFactory.cs
- TypeListConverter.cs
- Duration.cs
- SatelliteContractVersionAttribute.cs
- DataGridPagerStyle.cs
- DataRowChangeEvent.cs
- TableLayoutSettingsTypeConverter.cs
- ContentElement.cs
- LowerCaseStringConverter.cs
- DataGridViewCheckBoxCell.cs
- listitem.cs
- COM2FontConverter.cs
- SchemaNamespaceManager.cs
- TextMarkerSource.cs
- OAVariantLib.cs
- CacheMode.cs
- UdpReplyToBehavior.cs
- CompiledIdentityConstraint.cs
- TailCallAnalyzer.cs
- TrustManager.cs
- PropertyGroupDescription.cs
- UpdateRecord.cs
- ComponentCommands.cs
- ConstantSlot.cs
- SortedSet.cs
- HtmlString.cs
- NamespaceQuery.cs
- TakeOrSkipWhileQueryOperator.cs
- ListDataHelper.cs
- TextEndOfLine.cs
- CharacterMetricsDictionary.cs
- ValidatorAttribute.cs
- DispatcherSynchronizationContext.cs
- ExclusiveCanonicalizationTransform.cs
- FormsAuthenticationCredentials.cs
- CoTaskMemHandle.cs