Mercurial > pub > bltoolkit
comparison Source/Reflection/ObjectFactoryAttribute.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 using System.Diagnostics.CodeAnalysis; | |
| 3 | |
| 4 namespace BLToolkit.Reflection | |
| 5 { | |
| 6 [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")] | |
| 7 [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)] | |
| 8 public class ObjectFactoryAttribute : Attribute | |
| 9 { | |
| 10 public ObjectFactoryAttribute(Type type) | |
| 11 { | |
| 12 if (type == null) throw new ArgumentNullException("type"); | |
| 13 | |
| 14 _objectFactory = Activator.CreateInstance(type) as IObjectFactory; | |
| 15 | |
| 16 if (_objectFactory == null) | |
| 17 throw new ArgumentException( | |
| 18 string.Format("Type '{0}' does not implement IObjectFactory interface.", type)); | |
| 19 } | |
| 20 | |
| 21 private readonly IObjectFactory _objectFactory; | |
| 22 public IObjectFactory ObjectFactory | |
| 23 { | |
| 24 get { return _objectFactory; } | |
| 25 } | |
| 26 } | |
| 27 } |
