Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / ndp / fx / src / CompMod / System / Diagnostics / DelimitedListTraceListener.cs / 1 / DelimitedListTraceListener.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Text; using System.Globalization; using System.IO; using System.Collections; using System.Security.Permissions; using System.Runtime.Versioning; namespace System.Diagnostics { [HostProtection(Synchronization=true)] public class DelimitedListTraceListener : TextWriterTraceListener { string delimiter = ";"; string secondaryDelim = ","; bool initializedDelim = false; public DelimitedListTraceListener(Stream stream) : base(stream) { } public DelimitedListTraceListener(Stream stream, string name) : base(stream, name) { } public DelimitedListTraceListener(TextWriter writer) : base(writer) { } public DelimitedListTraceListener(TextWriter writer, string name) : base(writer, name) { } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] public DelimitedListTraceListener(string fileName) : base (fileName) { } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] public DelimitedListTraceListener(string fileName, string name) : base(fileName, name) { } public string Delimiter { get { lock(this) { // Probably overkill if (!initializedDelim) { if (Attributes.ContainsKey("delimiter")) delimiter = Attributes["delimiter"]; initializedDelim = true; } } return delimiter; } set { if (value == null) throw new ArgumentNullException("Delimiter"); if (value.Length == 0) throw new ArgumentException(SR.GetString("Generic_ArgCantBeEmptyString", "Delimiter")); lock(this) { delimiter = value; initializedDelim = true; } if (delimiter == ",") secondaryDelim = ";"; else secondaryDelim = ","; } } protected override internal string[] GetSupportedAttributes() { return new String[]{"delimiter"}; } public override void TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, int id, string format, params object[] args) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args)) return; WriteHeader(source, eventType, id); if (args != null) WriteEscaped(String.Format(CultureInfo.InvariantCulture, format, args)); else WriteEscaped(format); Write(Delimiter); // Use get_Delimiter // one more delimiter for the data object Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); } public override void TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, int id, string message) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, message)) return; WriteHeader(source, eventType, id); WriteEscaped(message); Write(Delimiter); // Use get_Delimiter // one more delimiter for the data object Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); } public override void TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, int id, object data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data)) return; WriteHeader(source, eventType, id); // first a delimiter for the message Write(Delimiter); // Use get_Delimiter WriteEscaped(data.ToString()); Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); } public override void TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, int id, params object[] data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, null, data)) return; WriteHeader(source, eventType, id); // first a delimiter for the message Write(Delimiter); // Use get_Delimiter if (data != null) { for (int i=0; i// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- using System; using System.Text; using System.Globalization; using System.IO; using System.Collections; using System.Security.Permissions; using System.Runtime.Versioning; namespace System.Diagnostics { [HostProtection(Synchronization=true)] public class DelimitedListTraceListener : TextWriterTraceListener { string delimiter = ";"; string secondaryDelim = ","; bool initializedDelim = false; public DelimitedListTraceListener(Stream stream) : base(stream) { } public DelimitedListTraceListener(Stream stream, string name) : base(stream, name) { } public DelimitedListTraceListener(TextWriter writer) : base(writer) { } public DelimitedListTraceListener(TextWriter writer, string name) : base(writer, name) { } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] public DelimitedListTraceListener(string fileName) : base (fileName) { } [ResourceExposure(ResourceScope.Machine)] [ResourceConsumption(ResourceScope.Machine)] public DelimitedListTraceListener(string fileName, string name) : base(fileName, name) { } public string Delimiter { get { lock(this) { // Probably overkill if (!initializedDelim) { if (Attributes.ContainsKey("delimiter")) delimiter = Attributes["delimiter"]; initializedDelim = true; } } return delimiter; } set { if (value == null) throw new ArgumentNullException("Delimiter"); if (value.Length == 0) throw new ArgumentException(SR.GetString("Generic_ArgCantBeEmptyString", "Delimiter")); lock(this) { delimiter = value; initializedDelim = true; } if (delimiter == ",") secondaryDelim = ";"; else secondaryDelim = ","; } } protected override internal string[] GetSupportedAttributes() { return new String[]{"delimiter"}; } public override void TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, int id, string format, params object[] args) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, format, args)) return; WriteHeader(source, eventType, id); if (args != null) WriteEscaped(String.Format(CultureInfo.InvariantCulture, format, args)); else WriteEscaped(format); Write(Delimiter); // Use get_Delimiter // one more delimiter for the data object Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); } public override void TraceEvent(TraceEventCache eventCache, String source, TraceEventType eventType, int id, string message) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, message)) return; WriteHeader(source, eventType, id); WriteEscaped(message); Write(Delimiter); // Use get_Delimiter // one more delimiter for the data object Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); } public override void TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, int id, object data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, data)) return; WriteHeader(source, eventType, id); // first a delimiter for the message Write(Delimiter); // Use get_Delimiter WriteEscaped(data.ToString()); Write(Delimiter); // Use get_Delimiter WriteFooter(eventCache); } public override void TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, int id, params object[] data) { if (Filter != null && !Filter.ShouldTrace(eventCache, source, eventType, id, null, null, null, data)) return; WriteHeader(source, eventType, id); // first a delimiter for the message Write(Delimiter); // Use get_Delimiter if (data != null) { for (int i=0; i
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- StringUtil.cs
- CodeGenerator.cs
- WebHttpBindingElement.cs
- KnownBoxes.cs
- FigureHelper.cs
- QuadTree.cs
- DataObjectSettingDataEventArgs.cs
- GridViewDeletedEventArgs.cs
- RelativeSource.cs
- DataGridLinkButton.cs
- AsymmetricCryptoHandle.cs
- TextEditorParagraphs.cs
- Int32CollectionValueSerializer.cs
- SendKeys.cs
- NullRuntimeConfig.cs
- ThaiBuddhistCalendar.cs
- AllMembershipCondition.cs
- PropertyDescriptor.cs
- InkCollectionBehavior.cs
- PresentationAppDomainManager.cs
- TransformGroup.cs
- Delegate.cs
- EntityDataSourceValidationException.cs
- Stacktrace.cs
- TypeConverters.cs
- SchemaUtility.cs
- FontCacheUtil.cs
- sqlser.cs
- DataStorage.cs
- controlskin.cs
- PeerMaintainer.cs
- UserMapPath.cs
- XmlAnyElementAttributes.cs
- MessageSmuggler.cs
- DataBinder.cs
- BitmapEffectRenderDataResource.cs
- TabControlCancelEvent.cs
- TextDecorationLocationValidation.cs
- MessagePartSpecification.cs
- ToolStrip.cs
- PerspectiveCamera.cs
- LabelDesigner.cs
- UIElement3DAutomationPeer.cs
- IteratorDescriptor.cs
- MsmqIntegrationBindingElement.cs
- newinstructionaction.cs
- MessageAction.cs
- ProgressChangedEventArgs.cs
- PnrpPeerResolverElement.cs
- AccessedThroughPropertyAttribute.cs
- SchemaDeclBase.cs
- AssociationSetEnd.cs
- SelectionEditingBehavior.cs
- SqlDataSourceQueryConverter.cs
- TextSimpleMarkerProperties.cs
- NetMsmqBinding.cs
- MailDefinitionBodyFileNameEditor.cs
- Renderer.cs
- MultipleViewPattern.cs
- HttpApplication.cs
- KeyInfo.cs
- FixedSOMTable.cs
- MimePart.cs
- SiteMapProvider.cs
- XmlCharacterData.cs
- IChannel.cs
- XmlSequenceWriter.cs
- DataTableNameHandler.cs
- ScriptIgnoreAttribute.cs
- Matrix3DStack.cs
- HotSpot.cs
- ValidatingPropertiesEventArgs.cs
- BamlRecordWriter.cs
- StateMachineWorkflowInstance.cs
- DataGridViewColumnDividerDoubleClickEventArgs.cs
- GridSplitterAutomationPeer.cs
- GatewayDefinition.cs
- HttpChannelBindingToken.cs
- WebPartEditorOkVerb.cs
- SdlChannelSink.cs
- XmlAtomicValue.cs
- NamespaceTable.cs
- OutOfMemoryException.cs
- WindowsListViewScroll.cs
- XmlSigningNodeWriter.cs
- DocumentPageView.cs
- UrlPath.cs
- DataGridLength.cs
- CodeTypeReference.cs
- _DomainName.cs
- ProtocolElementCollection.cs
- ConfigXmlAttribute.cs
- MasterPageParser.cs
- Reference.cs
- ProfileProvider.cs
- TableItemStyle.cs
- CodeAttributeArgumentCollection.cs
- LocalizeDesigner.cs
- HttpDebugHandler.cs
- GrammarBuilderPhrase.cs