Mercurial > pub > bltoolkit
comparison Source/Aspects/MixinAttribute.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(AttributeTargets.Class, AllowMultiple=true)] | |
11 public sealed class MixinAttribute : AbstractTypeBuilderAttribute | |
12 { | |
13 public MixinAttribute( | |
14 Type targetInterface, string memberName, bool throwExceptionIfNull, string exceptionMessage) | |
15 { | |
16 _targetInterface = targetInterface; | |
17 _memberName = memberName; | |
18 _throwExceptionIfNull = throwExceptionIfNull; | |
19 _exceptionMessage = exceptionMessage; | |
20 } | |
21 | |
22 public MixinAttribute(Type targetInterface, string memberName, bool throwExceptionIfNull) | |
23 : this(targetInterface, memberName, throwExceptionIfNull, null) | |
24 { | |
25 } | |
26 | |
27 public MixinAttribute(Type targetInterface, string memberName, string exceptionMessage) | |
28 : this(targetInterface, memberName, true, exceptionMessage) | |
29 { | |
30 } | |
31 | |
32 public MixinAttribute(Type targetInterface, string memberName) | |
33 : this(targetInterface, memberName, true, null) | |
34 { | |
35 } | |
36 | |
37 private readonly Type _targetInterface; | |
38 public Type TargetInterface | |
39 { | |
40 get { return _targetInterface; } | |
41 } | |
42 | |
43 private readonly string _memberName; | |
44 public string MemberName | |
45 { | |
46 get { return _memberName; } | |
47 } | |
48 | |
49 private bool _throwExceptionIfNull; | |
50 public bool ThrowExceptionIfNull | |
51 { | |
52 get { return _throwExceptionIfNull; } | |
53 set { _throwExceptionIfNull = value; } | |
54 } | |
55 | |
56 private string _exceptionMessage; | |
57 public string ExceptionMessage | |
58 { | |
59 get { return _exceptionMessage; } | |
60 set { _exceptionMessage = value; } | |
61 } | |
62 | |
63 public override IAbstractTypeBuilder TypeBuilder | |
64 { | |
65 get | |
66 { | |
67 return new Builders.MixinAspectBuilder( | |
68 _targetInterface, _memberName, _throwExceptionIfNull, _exceptionMessage); | |
69 } | |
70 } | |
71 } | |
72 } |