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
- BuildManager.cs
- CrossSiteScriptingValidation.cs
- ObjectTypeMapping.cs
- FormsAuthenticationConfiguration.cs
- DllHostInitializer.cs
- ItemContainerGenerator.cs
- SocketAddress.cs
- ItemCheckedEvent.cs
- PerformanceCounterLib.cs
- DataTableNewRowEvent.cs
- DataStreamFromComStream.cs
- TextServicesContext.cs
- BaseParser.cs
- PenContexts.cs
- OdbcConnection.cs
- DefinitionBase.cs
- RegistryDataKey.cs
- DefaultValueAttribute.cs
- CompilerGlobalScopeAttribute.cs
- _DisconnectOverlappedAsyncResult.cs
- DrawListViewColumnHeaderEventArgs.cs
- MsmqIntegrationChannelListener.cs
- SiteMapNodeCollection.cs
- XsltContext.cs
- SettingsProperty.cs
- updateconfighost.cs
- ModelFunction.cs
- ping.cs
- RegexCharClass.cs
- Menu.cs
- CodeNamespaceImport.cs
- BeginEvent.cs
- ComponentConverter.cs
- SortDescription.cs
- CodeIdentifier.cs
- WebPartZone.cs
- TextClipboardData.cs
- RootBuilder.cs
- ConsumerConnectionPoint.cs
- TransactionChannelListener.cs
- ConstraintStruct.cs
- Gdiplus.cs
- __Filters.cs
- TextMarkerSource.cs
- InheritablePropertyChangeInfo.cs
- GlyphInfoList.cs
- ToolZone.cs
- VirtualDirectoryMapping.cs
- SafeLibraryHandle.cs
- HtmlCalendarAdapter.cs
- HintTextMaxWidthConverter.cs
- CacheAxisQuery.cs
- HScrollProperties.cs
- RoleGroupCollectionEditor.cs
- StateItem.cs
- ObjectConverter.cs
- DecimalKeyFrameCollection.cs
- DbConnectionClosed.cs
- Property.cs
- ApplicationSecurityInfo.cs
- CatalogPartCollection.cs
- WebMessageEncodingBindingElement.cs
- WebPartsSection.cs
- Converter.cs
- NotCondition.cs
- HttpCookiesSection.cs
- AsyncCompletedEventArgs.cs
- Point.cs
- Vector3D.cs
- SessionPageStatePersister.cs
- SamlSecurityToken.cs
- AppDomain.cs
- thaishape.cs
- MailWebEventProvider.cs
- TrackingProfileCache.cs
- OperationPickerDialog.cs
- TdsParserSafeHandles.cs
- XamlTypeMapper.cs
- HttpProcessUtility.cs
- ObjectConverter.cs
- ReachSerializableProperties.cs
- StylusDevice.cs
- ExtendedProperty.cs
- MultiSelector.cs
- TraceSwitch.cs
- XmlSiteMapProvider.cs
- ScriptComponentDescriptor.cs
- AnonymousIdentificationSection.cs
- OpacityConverter.cs
- StringSource.cs
- ResetableIterator.cs
- ListViewCancelEventArgs.cs
- MdiWindowListStrip.cs
- XmlSerializerAssemblyAttribute.cs
- ConsoleKeyInfo.cs
- XmlDocument.cs
- FieldToken.cs
- BuiltInPermissionSets.cs
- DataBoundControlHelper.cs
- ChannelSinkStacks.cs