Debian Codegraph @

external/ikvm/reflect/Emit/EnumBuilder.cs

raw
1 /*
2 Copyright (C) 2010 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 [email protected]
22
23 */
24 using System;
25 using System.Collections.Generic;
26 using System.Text;
27
28 namespace IKVM.Reflection.Emit
29 {
30 public sealed class EnumBuilder : TypeInfo
31 {
32 private readonly TypeBuilder typeBuilder;
33 private readonly FieldBuilder fieldBuilder;
34
35 internal EnumBuilder(TypeBuilder typeBuilder, FieldBuilder fieldBuilder)
36 : base(typeBuilder)
37 {
38 this.typeBuilder = typeBuilder;
39 this.fieldBuilder = fieldBuilder;
40 }
41
42 internal override TypeName TypeName
43 {
44 get { return typeBuilder.TypeName; }
45 }
46
47 public override string Name
48 {
49 get { return typeBuilder.Name; }
50 }
51
52 public override string FullName
53 {
54 get { return typeBuilder.FullName; }
55 }
56
57 public override Type BaseType
58 {
59 get { return typeBuilder.BaseType; }
60 }
61
62 public override TypeAttributes Attributes
63 {
64 get { return typeBuilder.Attributes; }
65 }
66
67 public override Module Module
68 {
69 get { return typeBuilder.Module; }
70 }
71
72 public FieldBuilder DefineLiteral(string literalName, object literalValue)
73 {
74 FieldBuilder fb = typeBuilder.DefineField(literalName, typeBuilder, FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal);
75 fb.SetConstant(literalValue);
76 return fb;
77 }
78
79 public Type CreateType()
80 {
81 return typeBuilder.CreateType();
82 }
83
84 public TypeInfo CreateTypeInfo()
85 {
86 return typeBuilder.CreateTypeInfo();
87 }
88
89 public TypeToken TypeToken
90 {
91 get { return typeBuilder.TypeToken; }
92 }
93
94 public FieldBuilder UnderlyingField
95 {
96 get { return fieldBuilder; }
97 }
98
99 public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
100 {
101 typeBuilder.SetCustomAttribute(con, binaryAttribute);
102 }
103
104 public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
105 {
106 typeBuilder.SetCustomAttribute(customBuilder);
107 }
108
109 public override Type GetEnumUnderlyingType()
110 {
111 return fieldBuilder.FieldType;
112 }
113
114 internal override bool IsBaked
115 {
116 get { return typeBuilder.IsBaked; }
117 }
118 }
119 }