Mercurial > pub > bltoolkit
comparison Source/Reflection/Emit/ConstructorBuilderHelper.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.Reflection.Emit; | |
3 | |
4 namespace BLToolkit.Reflection.Emit | |
5 { | |
6 /// <summary> | |
7 /// A wrapper around the <see cref="ConstructorBuilder"/> class. | |
8 /// </summary> | |
9 public class ConstructorBuilderHelper : MethodBuilderBase | |
10 { | |
11 /// <summary> | |
12 /// Initializes a new instance of the <see cref="ConstructorBuilder"/> class | |
13 /// with the specified parameters. | |
14 /// </summary> | |
15 /// <param name="typeBuilder">Associated <see cref="TypeBuilderHelper"/>.</param> | |
16 /// <param name="constructorBuilder">A <see cref="ConstructorBuilder"/></param> | |
17 public ConstructorBuilderHelper(TypeBuilderHelper typeBuilder, ConstructorBuilder constructorBuilder) | |
18 : base(typeBuilder) | |
19 { | |
20 if (constructorBuilder == null) throw new ArgumentNullException("constructorBuilder"); | |
21 | |
22 _constructorBuilder = constructorBuilder; | |
23 _constructorBuilder.SetCustomAttribute(Type.Assembly.BLToolkitAttribute); | |
24 } | |
25 | |
26 private readonly ConstructorBuilder _constructorBuilder; | |
27 /// <summary> | |
28 /// Gets ConstructorBuilder. | |
29 /// </summary> | |
30 public ConstructorBuilder ConstructorBuilder | |
31 { | |
32 get { return _constructorBuilder; } | |
33 } | |
34 | |
35 /// <summary> | |
36 /// Converts the supplied <see cref="ConstructorBuilderHelper"/> to a <see cref="MethodBuilder"/>. | |
37 /// </summary> | |
38 /// <param name="constructorBuilder">The <see cref="ConstructorBuilder"/>.</param> | |
39 /// <returns>A <see cref="ConstructorBuilder"/>.</returns> | |
40 public static implicit operator ConstructorBuilder(ConstructorBuilderHelper constructorBuilder) | |
41 { | |
42 if (constructorBuilder == null) throw new ArgumentNullException("constructorBuilder"); | |
43 | |
44 return constructorBuilder.ConstructorBuilder; | |
45 } | |
46 | |
47 private EmitHelper _emitter; | |
48 /// <summary> | |
49 /// Gets <see cref="EmitHelper"/>. | |
50 /// </summary> | |
51 public override EmitHelper Emitter | |
52 { | |
53 get | |
54 { | |
55 if (_emitter == null) | |
56 _emitter = new EmitHelper(this, _constructorBuilder.GetILGenerator()); | |
57 | |
58 return _emitter; | |
59 } | |
60 } | |
61 } | |
62 } |