The Labs \ Source Viewer \ SSCLI \ System.Diagnostics \ SourceFilter

  1. //------------------------------------------------------------------------------
  2. // <copyright file="SourceFilter.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. using System;
  16. using System.Collections;
  17. namespace System.Diagnostics
  18. {
  19.     public class SourceFilter : TraceFilter
  20.     {
  21.         private string src;
  22.        
  23.         public SourceFilter(string source)
  24.         {
  25.             Source = source;
  26.         }
  27.        
  28.         public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id, string formatOrMessage, object[] args, object data1, object[] data)
  29.         {
  30.             if (source == null)
  31.                 throw new ArgumentNullException("source");
  32.            
  33.             return String.Equals(src, source);
  34.         }
  35.        
  36.         public string Source {
  37.             get { return src; }
  38.             set {
  39.                 if (value == null)
  40.                     throw new ArgumentNullException("source");
  41.                 src = value;
  42.             }
  43.         }
  44.     }
  45. }

Developer Fusion