Пример #1
0
        /// <summary>
        /// Creates a new <see cref="PropertyFilter"/>
        /// </summary>
        /// <param name="targetValue">The value against which log events are compared</param>
        /// <param name="operation">The operation used by this <see cref="PropertyFilter" /></param>
        /// <param name="propertyReader">The <see cref="PropertyReader"/> used by this <see cref="PropertyFilter"/></param>
        /// <param name="defaultEvaluation">The default evaluation of the filter in the event of a failure to read the property</param>
        public PropertyFilter(string targetValue, Operation operation, PropertyReader propertyReader, bool defaultEvaluation)
        {
            if (null == propertyReader)
                throw new ArgumentNullException("propertyReader");

            Initialize(targetValue, operation, propertyReader, defaultEvaluation);
        }
Пример #2
0
 private void Initialize(string value, Operation operation, PropertyReader propertyReader, bool defaultEvaluation)
 {
     DefaultEvaluation = defaultEvaluation;
     PropertyReader = propertyReader;
     Operation = operation;
     Validate();
     TargetValue = ParseValue(value);
 }
Пример #3
0
        /// <summary>
        /// Contructs a new instance of the FastPropertyReader
        /// </summary>
        /// <param name="wrappedPropertyReader">The <see cref="PropertyReader"/> to be wrapped</param>
        /// <param name="propertyName">The name of the property to be retrieved from the result</param>
        public FastPropertyReader(PropertyReader wrappedPropertyReader, string propertyName)
        {
            _fastPropertyGetter = new FastPropertyGetter(propertyName, wrappedPropertyReader.PropertyType);
            _wrappedPropertyReader = wrappedPropertyReader;

            if (_fastPropertyGetter.PropertyType == typeof(string))
            {
                _comparator = StringComparator.Instance;
            }
            else if (typeof(IConvertible).IsAssignableFrom(_fastPropertyGetter.PropertyType) &&
                     typeof(IComparable).IsAssignableFrom(_fastPropertyGetter.PropertyType))
            {
                _comparator = NumericComparator.Instance;
            }
            else
            {
                _comparator = ObjectComparator.Instance;
            }
        }
Пример #4
0
 /// <summary>
 /// Construct the listener
 /// </summary>
 /// <param name="valueToken">A property reader</param>
 public ConsoleTraceListener(string valueToken)
     : base("OutputDebugStringTraceListener")
 {
     _propertyReader = DefaultServiceLocator.GetService<IPropertyReaderFactory>().CreateCombinedReader(valueToken);
 }
Пример #5
0
 /// <inheritdoc />
 public FormattedPropertyReader(PropertyReader wrappedPropertyReader, string formatString)
 {
     _wrappedPropertyReader = wrappedPropertyReader;
     FormatString = formatString;
 }
Пример #6
0
        /// <summary>
        /// Adds a new token to the internal dictionary of propertyReader.
        /// </summary>
        /// <param name="token">The name of the token</param>
        /// <param name="propertyReader">The propertyReader that the token represents</param>
        /// <exception cref="System.ArgumentNullException">Thrown if the token or propertyReader parameters are null</exception>
        /// <exception cref="ArgumentException">Thrown if the given token is already in the internal dictionary, or if the token is a substring of an existing token</exception>
        public void AddToken(string token, PropertyReader propertyReader)
        {
            if (string.IsNullOrEmpty(token))
                throw new ArgumentNullException("token");
            if (null == propertyReader)
                throw new ArgumentNullException("propertyReader");

            lock (_padlock)
            {
                if (_readerTokenDictionary.ContainsKey(token))
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                              Resources.TokenAlreadyExists,
                                                              token));
                }


                _readerTokenDictionary.Add(token, propertyReader);
            }
        }
Пример #7
0
 /// <summary>
 /// Creates a new instance of the DebuggerTraceListener class
 /// </summary>
 /// <param name="valueToken"></param>
 public DebuggerTraceListener(string valueToken)
     : base("DebuggerTraceListener")
 {
     _propertyReader = DefaultServiceLocator.GetService<IPropertyReaderFactory>().CreateCombinedReader(valueToken);
 }
Пример #8
0
 /// <summary>
 /// Creates a new <see cref="PropertyFilter"/>
 /// </summary>
 /// <param name="targetValue">The value against which log events are compared</param>
 /// <param name="operation">The operation used by this <see cref="PropertyFilter" /></param>
 /// <param name="propertyReader">The <see cref="PropertyReader"/> used by this <see cref="PropertyFilter"/></param>
 public PropertyFilter(string targetValue, Operation operation, PropertyReader propertyReader)
     : this(targetValue, operation, propertyReader, true)
 {
 }
Пример #9
0
 /// <summary>
 /// Construct a SqlTraceParameter
 /// </summary>
 /// <param name="name">The name of the parameter</param>
 /// <param name="propertyReader">The property reader used to read it</param>
 /// <param name="callToString">True if .ToString() should be called</param>
 public SqlTraceParameter(string name, PropertyReader propertyReader, bool callToString)
 {
     Name = name;
     PropertyReader = propertyReader;
     CallToString = callToString;
 }
Пример #10
0
 /// <inheritdoc />
 public FormattedPropertyReader(PropertyReader wrappedPropertyReader, string formatString)
 {
     _wrappedPropertyReader = wrappedPropertyReader;
     FormatString           = formatString;
 }
Пример #11
0
 private void InternalConfigure(IPropertyReaderFactory readerFactory, ISmtpService smtpService, string host, int port, string username, string password, string to, string from,
                                string subjectValueToken, string bodyValueToken)
 {
     SmtpService = smtpService;
     SmtpService.Initialize(host, port, username, password);
     From = from;
     To = to;
     SubjectReader = readerFactory.CreateCombinedReader(subjectValueToken);
     BodyReader = readerFactory.CreateCombinedReader(bodyValueToken);
 }