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
- AssemblyAttributesGoHere.cs
- DataObject.cs
- NamespaceEmitter.cs
- ElementHost.cs
- SingleConverter.cs
- DataIdProcessor.cs
- SqlCacheDependencyDatabaseCollection.cs
- EventArgs.cs
- SQLString.cs
- MaterialGroup.cs
- TableAutomationPeer.cs
- ModelItemCollection.cs
- FixedNode.cs
- GridViewCommandEventArgs.cs
- OleDbRowUpdatingEvent.cs
- SystemIPv6InterfaceProperties.cs
- ProcessProtocolHandler.cs
- ConfigurationFileMap.cs
- XmlObjectSerializerReadContextComplex.cs
- StringArrayEditor.cs
- StructuralType.cs
- DataSourceControl.cs
- HttpTransportSecurityElement.cs
- TextEffect.cs
- DictionaryTraceRecord.cs
- UrlPath.cs
- StringDictionaryCodeDomSerializer.cs
- SectionInformation.cs
- DataGridItem.cs
- PointConverter.cs
- DataGridItemEventArgs.cs
- FormsAuthenticationEventArgs.cs
- Identity.cs
- RoleManagerEventArgs.cs
- XmlSchemaSimpleTypeList.cs
- ProviderConnectionPoint.cs
- localization.cs
- DiscoveryService.cs
- EntityDataSourceContextCreatedEventArgs.cs
- TypefaceCollection.cs
- QuotaThrottle.cs
- XmlHierarchicalDataSourceView.cs
- CurrentChangingEventArgs.cs
- AdRotator.cs
- StackOverflowException.cs
- DependsOnAttribute.cs
- CollectionTraceRecord.cs
- PageCache.cs
- DataGridTextBox.cs
- SmtpClient.cs
- InteropEnvironment.cs
- FileController.cs
- ArgIterator.cs
- RoleService.cs
- HandlerFactoryCache.cs
- NamedPipeConnectionPool.cs
- HtmlValidationSummaryAdapter.cs
- ElementProxy.cs
- PackageProperties.cs
- MobileControlsSectionHandler.cs
- DiscoveryDocumentSearchPattern.cs
- Rect3DValueSerializer.cs
- ToolStripDropDown.cs
- MergeLocalizationDirectives.cs
- ComplexLine.cs
- PartialList.cs
- LayoutEditorPart.cs
- ContainerUIElement3D.cs
- NoneExcludedImageIndexConverter.cs
- SQLUtility.cs
- PointLightBase.cs
- TrustManager.cs
- CheckBox.cs
- GlobalizationAssembly.cs
- EUCJPEncoding.cs
- DynamicRendererThreadManager.cs
- MenuScrollingVisibilityConverter.cs
- CompiledIdentityConstraint.cs
- StorageMappingItemCollection.cs
- LinqDataSource.cs
- ChildTable.cs
- QuestionEventArgs.cs
- CallbackHandler.cs
- XamlPathDataSerializer.cs
- AttachmentService.cs
- TableParaClient.cs
- EventToken.cs
- SafeThreadHandle.cs
- ServiceCredentialsElement.cs
- _OSSOCK.cs
- ListViewDataItem.cs
- CodePrimitiveExpression.cs
- XslAstAnalyzer.cs
- DataGridItemCollection.cs
- RuleValidation.cs
- _AutoWebProxyScriptHelper.cs
- DataGridViewCellStateChangedEventArgs.cs
- PersonalizationProvider.cs
- SimpleHandlerFactory.cs
- SerializerWriterEventHandlers.cs