annotate Source/Mapping/ObjectMapperAttribute.cs @ 9:1e85f66cf767 default tip

update bltoolkit
author nickolay
date Thu, 05 Apr 2018 20:53:26 +0300
parents f990fcb411a9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
1 using System;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
2
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
3 namespace BLToolkit.Mapping
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
4 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
5 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
6 public sealed class ObjectMapperAttribute : Attribute
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
7 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
8 public ObjectMapperAttribute(Type objectMapperType)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
9 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
10 if (objectMapperType == null) throw new ArgumentNullException("objectMapperType");
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
11
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
12 _objectMapper = Activator.CreateInstance(objectMapperType) as ObjectMapper;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
13
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
14 if (_objectMapper == null)
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
15 throw new ArgumentException(
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
16 string.Format("Type '{0}' does not implement IObjectMapper interface.", objectMapperType));
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
17 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
18
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
19 private readonly ObjectMapper _objectMapper;
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
20 public ObjectMapper ObjectMapper
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
21 {
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
22 get { return _objectMapper; }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
23 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
24 }
f990fcb411a9 Копия текущей версии из github
cin
parents:
diff changeset
25 }