Code:
/ 4.0 / 4.0 / untmp / 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
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CompiledIdentityConstraint.cs
- PeerContact.cs
- PreservationFileReader.cs
- ConsoleCancelEventArgs.cs
- DrawingAttributeSerializer.cs
- MimeTypePropertyAttribute.cs
- EnvelopedPkcs7.cs
- ThemeDictionaryExtension.cs
- MenuAdapter.cs
- XmlAttributes.cs
- XpsFilter.cs
- SystemEvents.cs
- DataGridHyperlinkColumn.cs
- TileModeValidation.cs
- Ticks.cs
- TaskFormBase.cs
- SmiMetaDataProperty.cs
- SqlConnectionFactory.cs
- HandlerFactoryCache.cs
- DataTableReaderListener.cs
- InstanceOwnerQueryResult.cs
- HMACSHA384.cs
- HotCommands.cs
- CachedBitmap.cs
- XmlSchemaExporter.cs
- MethodResolver.cs
- SmiEventSink.cs
- Animatable.cs
- IsolatedStorageException.cs
- ByteStreamGeometryContext.cs
- Activity.cs
- serverconfig.cs
- FilterFactory.cs
- FixedDSBuilder.cs
- VisualStyleRenderer.cs
- IListConverters.cs
- PointConverter.cs
- DataGridViewRowConverter.cs
- ArcSegment.cs
- StylusOverProperty.cs
- FixedSOMPageElement.cs
- FilterableAttribute.cs
- XsdBuildProvider.cs
- PrimitiveCodeDomSerializer.cs
- ProcessStartInfo.cs
- StatusBarPanel.cs
- SoapElementAttribute.cs
- EventToken.cs
- HostingEnvironment.cs
- ClrPerspective.cs
- XmlDataLoader.cs
- UidPropertyAttribute.cs
- DirectoryNotFoundException.cs
- DeleteHelper.cs
- ObjectItemCollectionAssemblyCacheEntry.cs
- UnsafeNativeMethods.cs
- ExecutionPropertyManager.cs
- TransformConverter.cs
- Synchronization.cs
- XsltArgumentList.cs
- WindowsToolbarItemAsMenuItem.cs
- _Win32.cs
- ColumnCollection.cs
- XmlTypeAttribute.cs
- EncodingTable.cs
- XmlEntity.cs
- IMembershipProvider.cs
- PathSegmentCollection.cs
- TransformProviderWrapper.cs
- DateTimeOffset.cs
- WebPartEditVerb.cs
- DataObjectEventArgs.cs
- OutputWindow.cs
- Visual3D.cs
- IdentifierElement.cs
- FontFamily.cs
- WarningException.cs
- ActionMessageFilter.cs
- StringExpressionSet.cs
- CngProperty.cs
- SchemaCollectionPreprocessor.cs
- APCustomTypeDescriptor.cs
- ToolboxBitmapAttribute.cs
- HandleTable.cs
- RegistryPermission.cs
- AllMembershipCondition.cs
- IntPtr.cs
- MappingSource.cs
- WMICapabilities.cs
- ActivationServices.cs
- DbConnectionPoolCounters.cs
- BrowserCapabilitiesCodeGenerator.cs
- CqlLexer.cs
- BindingEditor.xaml.cs
- XPathNavigatorReader.cs
- InitializerFacet.cs
- Timeline.cs
- FormsAuthentication.cs
- ImageListStreamer.cs
- HijriCalendar.cs