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
- ControlBuilderAttribute.cs
- Cursor.cs
- HeaderCollection.cs
- OptimisticConcurrencyException.cs
- BaseTemplateCodeDomTreeGenerator.cs
- StringUtil.cs
- BuiltInExpr.cs
- XmlDocumentViewSchema.cs
- PersonalizationStateInfoCollection.cs
- ExpressionBindingCollection.cs
- SqlXml.cs
- DeclaredTypeValidatorAttribute.cs
- BamlTreeMap.cs
- CompositeControlDesigner.cs
- ExtensionFile.cs
- BitmapEffectInput.cs
- PerfService.cs
- PersonalizationProviderHelper.cs
- PageThemeParser.cs
- PositiveTimeSpanValidator.cs
- FastEncoder.cs
- CryptoProvider.cs
- CuspData.cs
- MeasureData.cs
- SchemaSetCompiler.cs
- TextSchema.cs
- PreviewPageInfo.cs
- ClaimTypes.cs
- DataRecordInfo.cs
- InkCanvas.cs
- OracleRowUpdatingEventArgs.cs
- EntityConnectionStringBuilder.cs
- BaseHashHelper.cs
- CodeCatchClauseCollection.cs
- ConfigurationHandlersInstallComponent.cs
- Pkcs7Signer.cs
- DefaultProxySection.cs
- ModuleBuilderData.cs
- CmsInterop.cs
- ItemsControlAutomationPeer.cs
- ListViewItemEventArgs.cs
- KeyboardNavigation.cs
- AutomationPeer.cs
- FormsIdentity.cs
- BrowserCapabilitiesFactory.cs
- BaseDataList.cs
- GetPageNumberCompletedEventArgs.cs
- SqlMultiplexer.cs
- TreeNodeEventArgs.cs
- Thickness.cs
- StorageSetMapping.cs
- AnnotationAuthorChangedEventArgs.cs
- PrincipalPermission.cs
- UserValidatedEventArgs.cs
- WS2007HttpBinding.cs
- Cursors.cs
- SmiConnection.cs
- OverflowException.cs
- BlockUIContainer.cs
- MethodCallExpression.cs
- DeviceSpecificChoice.cs
- FormParameter.cs
- Pkcs7Recipient.cs
- LocalizabilityAttribute.cs
- XmlNamespaceDeclarationsAttribute.cs
- HwndMouseInputProvider.cs
- SoapExtensionTypeElementCollection.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- DoubleLink.cs
- XamlTypeMapper.cs
- DynamicEndpointElement.cs
- ProfileServiceManager.cs
- WebPartsPersonalizationAuthorization.cs
- CounterSample.cs
- Padding.cs
- SqlDataSourceFilteringEventArgs.cs
- Vector3D.cs
- XsdDuration.cs
- ContractCodeDomInfo.cs
- sqlinternaltransaction.cs
- SmiXetterAccessMap.cs
- SafeNativeMethodsMilCoreApi.cs
- ByteAnimationUsingKeyFrames.cs
- ZipIOExtraFieldPaddingElement.cs
- XmlElement.cs
- JsonWriterDelegator.cs
- StrongNameUtility.cs
- ProviderUtil.cs
- DEREncoding.cs
- PolicyException.cs
- IdentitySection.cs
- SignedInfo.cs
- WindowsListViewItemCheckBox.cs
- PtsPage.cs
- Expression.DebuggerProxy.cs
- OdbcReferenceCollection.cs
- XmlSchemaAnnotated.cs
- MessageQueueException.cs
- CachedRequestParams.cs
- DbConnectionPool.cs