Mercurial > pub > bltoolkit
comparison Source/Mapping/MemberMapperAttribute.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 namespace BLToolkit.Mapping | |
| 4 { | |
| 5 [AttributeUsage( | |
| 6 AttributeTargets.Class | AttributeTargets.Interface | | |
| 7 AttributeTargets.Property | AttributeTargets.Field, | |
| 8 AllowMultiple=true)] | |
| 9 public class MemberMapperAttribute : MapImplicitAttribute | |
| 10 { | |
| 11 public MemberMapperAttribute(Type memberMapperType) | |
| 12 : this(null, memberMapperType) | |
| 13 { | |
| 14 } | |
| 15 | |
| 16 public MemberMapperAttribute(Type memberType, Type memberMapperType) | |
| 17 { | |
| 18 if (memberMapperType == null) throw new ArgumentNullException("memberMapperType"); | |
| 19 | |
| 20 _memberType = memberType; | |
| 21 _memberMapperType = memberMapperType; | |
| 22 } | |
| 23 | |
| 24 private readonly Type _memberType; | |
| 25 public Type MemberType | |
| 26 { | |
| 27 get { return _memberType; } | |
| 28 } | |
| 29 | |
| 30 private readonly Type _memberMapperType; | |
| 31 public Type MemberMapperType | |
| 32 { | |
| 33 get { return _memberMapperType; } | |
| 34 } | |
| 35 | |
| 36 public virtual MemberMapper MemberMapper | |
| 37 { | |
| 38 get | |
| 39 { | |
| 40 var mm = Activator.CreateInstance(_memberMapperType) as MemberMapper; | |
| 41 | |
| 42 if (mm == null) | |
| 43 throw new ArgumentException( | |
| 44 string.Format("Type '{0}' is not MemberMapper.", _memberMapperType)); | |
| 45 | |
| 46 mm.IsExplicit = true; | |
| 47 | |
| 48 return mm; | |
| 49 } | |
| 50 } | |
| 51 } | |
| 52 } |
