Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / CompMod / System / Diagnostics / DelimitedListTraceListener.cs / 1305376 / 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
- StackBuilderSink.cs
- MimeMapping.cs
- TriState.cs
- BrushConverter.cs
- ToolStripRenderEventArgs.cs
- CodeThrowExceptionStatement.cs
- basemetadatamappingvisitor.cs
- RNGCryptoServiceProvider.cs
- HtmlInputHidden.cs
- OleDbErrorCollection.cs
- SqlCharStream.cs
- EntityDataSourceColumn.cs
- DiagnosticsConfiguration.cs
- PathParser.cs
- entitydatasourceentitysetnameconverter.cs
- FormsAuthenticationEventArgs.cs
- DummyDataSource.cs
- IODescriptionAttribute.cs
- TabControlAutomationPeer.cs
- MemberHolder.cs
- CodeTryCatchFinallyStatement.cs
- CalloutQueueItem.cs
- SqlClientPermission.cs
- RegexCapture.cs
- HandlerBase.cs
- FileSecurity.cs
- PropertyGroupDescription.cs
- FixedHighlight.cs
- FixedSOMTextRun.cs
- TextViewBase.cs
- TableSectionStyle.cs
- FlowDecisionDesigner.xaml.cs
- PostBackTrigger.cs
- QueryPageSettingsEventArgs.cs
- InputDevice.cs
- AvTraceDetails.cs
- EditingMode.cs
- RuntimeConfig.cs
- TemplateParser.cs
- StringAnimationUsingKeyFrames.cs
- RoleService.cs
- DisableDpiAwarenessAttribute.cs
- SemanticBasicElement.cs
- DataGridViewTextBoxCell.cs
- NameTable.cs
- BasePattern.cs
- CalendarAutoFormat.cs
- SelectManyQueryOperator.cs
- storagemappingitemcollection.viewdictionary.cs
- StateValidator.cs
- ReferenceEqualityComparer.cs
- PackagePartCollection.cs
- AnchoredBlock.cs
- AdRotatorDesigner.cs
- TextContainerHelper.cs
- Binding.cs
- OleDbErrorCollection.cs
- xmlsaver.cs
- Selector.cs
- OracleBinary.cs
- ImageConverter.cs
- MonitorWrapper.cs
- RedBlackList.cs
- EdmItemCollection.cs
- BypassElementCollection.cs
- DataGridColumnHeadersPresenter.cs
- UIElementHelper.cs
- ClientUIRequest.cs
- Msmq.cs
- GridViewItemAutomationPeer.cs
- dbdatarecord.cs
- RegisteredArrayDeclaration.cs
- XpsResource.cs
- Constraint.cs
- StyleHelper.cs
- DataGridViewImageCell.cs
- DynamicQueryableWrapper.cs
- TableItemProviderWrapper.cs
- ControlBuilderAttribute.cs
- GestureRecognizer.cs
- PowerStatus.cs
- FtpRequestCacheValidator.cs
- CatalogPartCollection.cs
- ApplicationBuildProvider.cs
- VideoDrawing.cs
- WindowsListViewGroup.cs
- QueryFunctions.cs
- DataGridViewDataErrorEventArgs.cs
- PrimaryKeyTypeConverter.cs
- DataSvcMapFile.cs
- TypeDescriptionProvider.cs
- FormCollection.cs
- PropertyDescriptorCollection.cs
- QfeChecker.cs
- ActivityInstance.cs
- WebPartDisplayMode.cs
- SqlDelegatedTransaction.cs
- XmlSchemaParticle.cs
- PenThread.cs
- NamespaceQuery.cs