Mercurial > pub > bltoolkit
comparison Source/Aspects/LogAttribute.cs @ 0:f990fcb411a9
Копия текущей версии из github
author | cin |
---|---|
date | Thu, 27 Mar 2014 21:46:09 +0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f990fcb411a9 |
---|---|
1 using System; | |
2 | |
3 using BLToolkit.TypeBuilder.Builders; | |
4 | |
5 namespace BLToolkit.Aspects | |
6 { | |
7 /// <summary> | |
8 /// http://www.bltoolkit.net/Doc/Aspects/index.htm | |
9 /// </summary> | |
10 [AttributeUsage( | |
11 AttributeTargets.Class | | |
12 AttributeTargets.Interface | | |
13 AttributeTargets.Property | | |
14 AttributeTargets.Method, | |
15 AllowMultiple=true)] | |
16 public class LogAttribute : InterceptorAttribute | |
17 { | |
18 public LogAttribute() | |
19 : this(typeof(LoggingAspect), null) | |
20 { | |
21 } | |
22 | |
23 public LogAttribute(string parameters) | |
24 : this(typeof(LoggingAspect), parameters) | |
25 { | |
26 } | |
27 | |
28 protected LogAttribute(Type interceptorType, string parameters) | |
29 : base( | |
30 interceptorType, | |
31 InterceptType.OnCatch | InterceptType.OnFinally, | |
32 parameters, | |
33 TypeBuilderConsts.Priority.LoggingAspect) | |
34 { | |
35 } | |
36 | |
37 private bool _hasFileName; | |
38 private string _fileName; | |
39 public string FileName | |
40 { | |
41 get { return _fileName; } | |
42 set { _fileName = value; _hasFileName = true; } | |
43 } | |
44 | |
45 private bool _hasMinCallTime; | |
46 private int _minCallTime; | |
47 public int MinCallTime | |
48 { | |
49 get { return _minCallTime; } | |
50 set { _minCallTime = value; _hasMinCallTime = true; } | |
51 } | |
52 | |
53 private bool _hasLogExceptions; | |
54 private bool _logExceptions; | |
55 public bool LogExceptions | |
56 { | |
57 get { return _logExceptions; } | |
58 set { _logExceptions = value; _hasLogExceptions = true;} | |
59 } | |
60 | |
61 private bool _hasLogParameters; | |
62 private bool _logParameters; | |
63 public bool LogParameters | |
64 { | |
65 get { return _logParameters; } | |
66 set { _logParameters = value; _hasLogParameters = true;} | |
67 } | |
68 | |
69 public override string ConfigString | |
70 { | |
71 get | |
72 { | |
73 string s = base.ConfigString; | |
74 | |
75 if (_hasFileName) s += ";FileName=" + FileName; | |
76 if (_hasMinCallTime) s += ";MinCallTime=" + MinCallTime; | |
77 if (_hasLogExceptions) s += ";LogExceptions=" + LogExceptions; | |
78 if (_hasLogParameters) s += ";LogParameters=" + LogParameters; | |
79 | |
80 if (!string.IsNullOrEmpty(s) && s[0] == ';') | |
81 s = s.Substring(1); | |
82 | |
83 return s; | |
84 } | |
85 } | |
86 } | |
87 } |