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
- ListMarkerLine.cs
- PreProcessor.cs
- _AuthenticationState.cs
- NavigationPropertyEmitter.cs
- Delegate.cs
- VScrollBar.cs
- RelatedPropertyManager.cs
- EventLog.cs
- HashCodeCombiner.cs
- SchemaElementLookUpTableEnumerator.cs
- InternalEnumValidator.cs
- MruCache.cs
- BitmapEffectGeneralTransform.cs
- EntityCollection.cs
- InfoCardTrace.cs
- ListControl.cs
- DrawListViewItemEventArgs.cs
- NetworkInformationException.cs
- DBCSCodePageEncoding.cs
- EnumBuilder.cs
- EdmSchemaError.cs
- StorageMappingItemCollection.cs
- HtmlTitle.cs
- BamlLocalizabilityResolver.cs
- TagNameToTypeMapper.cs
- TableAutomationPeer.cs
- SqlBulkCopy.cs
- AppLevelCompilationSectionCache.cs
- Delegate.cs
- CodeSnippetExpression.cs
- SchemaInfo.cs
- Avt.cs
- ThreadStateException.cs
- StrokeIntersection.cs
- SymDocumentType.cs
- DefaultPropertyAttribute.cs
- HtmlHead.cs
- DataGridViewRowHeaderCell.cs
- UnmanagedMemoryStream.cs
- FilteredReadOnlyMetadataCollection.cs
- DisplayInformation.cs
- ProgressiveCrcCalculatingStream.cs
- PageWrapper.cs
- BrowserTree.cs
- ArrangedElement.cs
- DCSafeHandle.cs
- Substitution.cs
- Brushes.cs
- XmlQueryType.cs
- ReadContentAsBinaryHelper.cs
- WebPartConnectionsCloseVerb.cs
- InstanceNormalEvent.cs
- WindowsContainer.cs
- Padding.cs
- RenderData.cs
- ZipIOLocalFileBlock.cs
- FileSecurity.cs
- SequentialOutput.cs
- DynamicQueryableWrapper.cs
- SettingsBindableAttribute.cs
- LineSegment.cs
- AutomationProperties.cs
- SmtpFailedRecipientsException.cs
- DiscoveryDocumentLinksPattern.cs
- TemplateParser.cs
- AssemblySettingAttributes.cs
- LinearGradientBrush.cs
- SchemaImporterExtension.cs
- RepeaterCommandEventArgs.cs
- AxHost.cs
- WebBrowser.cs
- ReverseInheritProperty.cs
- WebServiceFault.cs
- UnsafePeerToPeerMethods.cs
- ContractComponent.cs
- CodeSnippetStatement.cs
- TemplatedMailWebEventProvider.cs
- RoleGroupCollection.cs
- SettingsBindableAttribute.cs
- SortKey.cs
- ISAPIWorkerRequest.cs
- SpeakProgressEventArgs.cs
- SQLBytesStorage.cs
- CompositeControl.cs
- AppDomainEvidenceFactory.cs
- PartialClassGenerationTaskInternal.cs
- FrameworkContentElement.cs
- OutputCacheProfile.cs
- ObjectListDataBindEventArgs.cs
- Compress.cs
- DataQuery.cs
- VScrollBar.cs
- AxImporter.cs
- TickBar.cs
- StdValidatorsAndConverters.cs
- ComNativeDescriptor.cs
- RangeValuePatternIdentifiers.cs
- InstanceHandleConflictException.cs
- ViewStateException.cs
- XmlSchemaInferenceException.cs