5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Copyright 2008 Novell, Inc. (http://www.novell.com)
9 * See the LICENSE file included with the distribution for details.
16 class FieldInfo
: MemberInfo
{
17 public TypeReference FieldType
;
18 public string BitField
;
25 get { return Name.EndsWith ("Event"); }
28 public string EventName
{
31 throw new System
.Exception (string.Format ("The field '{0}' doesn't represent an event", FullName
));
32 return Name
.Substring (0, Name
.LastIndexOf ("Event"));
36 public bool GenerateManagedEvent
{
38 string val
= Annotations
.GetValue ("GenerateManagedEvent");
39 if (val
== null || val
== "true")
44 throw new Exception ("Invalid value for 'GenerateManagedEvent'. Must be 'true' or 'false'");
48 public string EventDelegateType
{
50 string val
= Annotations
.GetValue ("DelegateType");
51 return val
?? "EventHandler";
55 public string DPAutoCreator
{
57 if (Annotations
.ContainsKey ("AutoCreator"))
58 return Annotations
.GetValue ("AutoCreator");
59 else if (Annotations
.ContainsKey ("AutoCreateValue"))
60 return "AutoCreators::default_autocreator";
66 public bool IsDPReadOnly
{
67 get { return Annotations.ContainsKey ("ReadOnly"); }
70 public bool IsDPAlwaysChange
{
71 get { return Annotations.ContainsKey ("AlwaysChange"); }
74 public bool IsDPAttached
{
75 get { return Annotations.ContainsKey ("Attached"); }
78 public bool IsDPNullable
{
79 get { return Annotations.ContainsKey ("Nullable"); }
82 public bool IsCustom
{
84 string val
= Annotations
.GetValue ("IsCustom");
85 if (val
== null || val
== "false")
90 throw new Exception ("Invalid value for 'SetsParent'. Must be 'true' or 'false'");
94 public string DPPropertyType
{
96 string result
= Annotations
.GetValue ("PropertyType");
103 return "PixelFormats";
111 public string DPDefaultValue
{
112 get { return Annotations.GetValue ("DefaultValue"); }
115 public string DPValidator
{
116 get { return Annotations.GetValue ("Validator"); }
119 public bool GenerateManagedAccessors
{
121 string val
= Annotations
.GetValue ("GenerateManagedAccessors");
122 if (val
== null || val
== "true")
127 throw new Exception ("Invalid value for 'GenerateManagedAccessors'. Must be 'true' or 'false'");
131 public TypeInfo
GetDPPropertyType (GlobalInfo all
)
133 string property_type
= DPPropertyType
;
134 TypeInfo propertyType
= null;
136 if (!string.IsNullOrEmpty (property_type
)) {
137 if (all
.Children
.ContainsKey (property_type
)) {
138 propertyType
= (TypeInfo
) all
.Children
[property_type
];
140 Console
.WriteLine ("{0}'s PropertyType '{1}' was not recognized. Do not use the Kind value, but the real type name.", FullName
, property_type
);
143 Console
.WriteLine ("{0} does not have a PropertyType defined.", FullName
);
149 public string GetAccess ()
151 string result
= Annotations
.GetValue ("Access");
152 return string.IsNullOrEmpty (result
) ? "Public" : result
;
155 public string GetManagedAccess ()
157 string result
= Annotations
.GetValue ("ManagedAccess");
158 return string.IsNullOrEmpty (result
) ? GetAccess () : result
;
161 public string GetManagedFieldAccess ()
163 string result
= Annotations
.GetValue ("ManagedFieldAccess");
164 return string.IsNullOrEmpty (result
) ? GetManagedAccess () : result
;
167 public string GetManagedGetterAccess ()
169 string result
= Annotations
.GetValue ("ManagedGetterAccess");
170 return string.IsNullOrEmpty (result
) ? GetManagedAccessorAccess () : result
;
173 public string GetManagedSetterAccess ()
175 string result
= Annotations
.GetValue ("ManagedSetterAccess");
176 return string.IsNullOrEmpty (result
) ? GetManagedAccessorAccess () : result
;
179 public string GetManagedAccessorAccess ()
181 string result
= Annotations
.GetValue ("ManagedAccessorAccess");
182 return string.IsNullOrEmpty (result
) ? GetManagedAccess () : result
;
185 public string GetDPManagedPropertyType (GlobalInfo all
)
187 string property_type
= Annotations
.GetValue ("ManagedPropertyType");
189 if (property_type
!= null)
190 return property_type
;
192 property_type
= Annotations
.GetValue ("PropertyType");
194 if (property_type
== null)
197 switch (property_type
) {
199 property_type
= "string"; break;
201 property_type
= "int"; break;
203 property_type
= "object"; break;
207 return "Nullable<" + property_type
+ ">";
209 return property_type
;
212 public string GetDependencyPropertyName ()
214 return Name
.Substring (0, Name
.LastIndexOf ("Property"));