0
|
1 using System;
|
|
2
|
|
3 namespace BLToolkit.Mapping
|
|
4 {
|
|
5 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
|
|
6 public sealed class ObjectMapperAttribute : Attribute
|
|
7 {
|
|
8 public ObjectMapperAttribute(Type objectMapperType)
|
|
9 {
|
|
10 if (objectMapperType == null) throw new ArgumentNullException("objectMapperType");
|
|
11
|
|
12 _objectMapper = Activator.CreateInstance(objectMapperType) as ObjectMapper;
|
|
13
|
|
14 if (_objectMapper == null)
|
|
15 throw new ArgumentException(
|
|
16 string.Format("Type '{0}' does not implement IObjectMapper interface.", objectMapperType));
|
|
17 }
|
|
18
|
|
19 private readonly ObjectMapper _objectMapper;
|
|
20 public ObjectMapper ObjectMapper
|
|
21 {
|
|
22 get { return _objectMapper; }
|
|
23 }
|
|
24 }
|
|
25 }
|