Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
- InheritablePropertyChangeInfo.cs
- ToolboxCategoryItems.cs
- AuthenticateEventArgs.cs
- DocumentPaginator.cs
- ProcessHostServerConfig.cs
- QuaternionConverter.cs
- BuildResultCache.cs
- DataGridViewRowPrePaintEventArgs.cs
- Viewport3DVisual.cs
- IntAverageAggregationOperator.cs
- StrokeNodeData.cs
- EditorPartChrome.cs
- ProcessModelSection.cs
- DataBindingList.cs
- tibetanshape.cs
- ArgumentNullException.cs
- ContextMarshalException.cs
- SignatureGenerator.cs
- AttachmentCollection.cs
- HttpCachePolicy.cs
- StreamGeometryContext.cs
- _SSPISessionCache.cs
- baseaxisquery.cs
- DoubleLink.cs
- Region.cs
- RSAOAEPKeyExchangeDeformatter.cs
- ParameterCollection.cs
- SafeEventLogWriteHandle.cs
- ObjectStateManager.cs
- EventLogEntry.cs
- TimeSpanStorage.cs
- WindowsNonControl.cs
- DataGridViewToolTip.cs
- LineGeometry.cs
- SpeechSynthesizer.cs
- DialogResultConverter.cs
- Misc.cs
- BCryptSafeHandles.cs
- BaseHashHelper.cs
- AspNetCacheProfileAttribute.cs
- DragEvent.cs
- HtmlTableCellCollection.cs
- BamlRecordWriter.cs
- CodeMethodInvokeExpression.cs
- ThousandthOfEmRealDoubles.cs
- XmlAttributeAttribute.cs
- CryptoApi.cs
- XmlSchemaCompilationSettings.cs
- TextSpanModifier.cs
- MeasurementDCInfo.cs
- ThemeDirectoryCompiler.cs
- ListViewContainer.cs
- FlowDocumentPage.cs
- OleDbErrorCollection.cs
- XamlPoint3DCollectionSerializer.cs
- PrintingPermissionAttribute.cs
- COM2ComponentEditor.cs
- DrawingContextDrawingContextWalker.cs
- RtType.cs
- EncodingInfo.cs
- ProxyRpc.cs
- CursorEditor.cs
- PrivilegedConfigurationManager.cs
- CodeTypeDeclaration.cs
- SiteMapHierarchicalDataSourceView.cs
- IssuerInformation.cs
- ComponentResourceKey.cs
- DataSourceCache.cs
- XmlSchemaAttributeGroupRef.cs
- NavigationCommands.cs
- UnsafeNativeMethods.cs
- XmlProcessingInstruction.cs
- Link.cs
- LinqDataSourceUpdateEventArgs.cs
- ChannelManagerService.cs
- SchemaElement.cs
- SettingsContext.cs
- Pair.cs
- ViewKeyConstraint.cs
- SQLGuid.cs
- PhysicalFontFamily.cs
- WebBrowser.cs
- TableCellAutomationPeer.cs
- State.cs
- ExpressionNode.cs
- ComplexType.cs
- WebBrowserContainer.cs
- SafeRegistryHandle.cs
- CompositeFontInfo.cs
- IdnMapping.cs
- XmlUtilWriter.cs
- StrokeNodeEnumerator.cs
- MessageAction.cs
- PropertyChangingEventArgs.cs
- Point3DCollectionConverter.cs
- DependentList.cs
- XmlMemberMapping.cs
- HtmlWindow.cs
- DelimitedListTraceListener.cs
- TrackingMemoryStream.cs