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 bool GenerateManagedEventField
{
50 string val
= Annotations
.GetValue ("GenerateManagedEventField");
51 if (val
== null || val
== "false")
56 throw new Exception ("Invalid value for 'GenerateManagedEventField'. Must be 'true' or 'false'");
60 public string EventDelegateType
{
62 string val
= Annotations
.GetValue ("DelegateType");
63 return val
?? "EventHandler";
67 public string DPAutoCreator
{
69 if (Annotations
.ContainsKey ("AutoCreator"))
70 return Annotations
.GetValue ("AutoCreator");
71 else if (Annotations
.ContainsKey ("AutoCreateValue"))
72 return "AutoCreators::default_autocreator";
78 public bool IsDPReadOnly
{
79 get { return Annotations.ContainsKey ("ReadOnly"); }
82 public bool IsDPAlwaysChange
{
83 get { return Annotations.ContainsKey ("AlwaysChange"); }
86 public bool IsDPAttached
{
87 get { return Annotations.ContainsKey ("Attached"); }
90 public bool IsDPNullable
{
91 get { return Annotations.ContainsKey ("Nullable"); }
94 public bool IsCustom
{
96 string val
= Annotations
.GetValue ("IsCustom");
97 if (val
== null || val
== "false")
102 throw new Exception ("Invalid value for 'SetsParent'. Must be 'true' or 'false'");
106 public string DPPropertyType
{
108 string result
= Annotations
.GetValue ("PropertyType");
110 if (result
!= null) {
115 return "PixelFormats";
123 public string DPDefaultValue
{
124 get { return Annotations.GetValue ("DefaultValue"); }
127 public string DPValidator
{
128 get { return Annotations.GetValue ("Validator"); }
131 public bool GenerateManagedAccessors
{
133 string val
= Annotations
.GetValue ("GenerateManagedAccessors");
134 if (val
== null || val
== "true")
139 throw new Exception ("Invalid value for 'GenerateManagedAccessors'. Must be 'true' or 'false'");
143 public TypeInfo
GetDPPropertyType (GlobalInfo all
)
145 string property_type
= DPPropertyType
;
146 TypeInfo propertyType
= null;
148 if (!string.IsNullOrEmpty (property_type
)) {
149 if (all
.Children
.ContainsKey (property_type
)) {
150 propertyType
= (TypeInfo
) all
.Children
[property_type
];
152 Console
.WriteLine ("{0}'s PropertyType '{1}' was not recognized. Do not use the Kind value, but the real type name.", FullName
, property_type
);
155 Console
.WriteLine ("{0} does not have a PropertyType defined.", FullName
);
161 public string GetAccess ()
163 string result
= Annotations
.GetValue ("Access");
164 return string.IsNullOrEmpty (result
) ? "Public" : result
;
167 public string GetManagedAccess ()
169 string result
= Annotations
.GetValue ("ManagedAccess");
170 return string.IsNullOrEmpty (result
) ? GetAccess () : result
;
173 public string GetManagedFieldAccess ()
175 string result
= Annotations
.GetValue ("ManagedFieldAccess");
176 return string.IsNullOrEmpty (result
) ? GetManagedAccess () : result
;
179 public string GetManagedGetterAccess ()
181 string result
= Annotations
.GetValue ("ManagedGetterAccess");
182 return string.IsNullOrEmpty (result
) ? GetManagedAccessorAccess () : result
;
185 public string GetManagedSetterAccess ()
187 string result
= Annotations
.GetValue ("ManagedSetterAccess");
188 return string.IsNullOrEmpty (result
) ? GetManagedAccessorAccess () : result
;
191 public string GetManagedAccessorAccess ()
193 string result
= Annotations
.GetValue ("ManagedAccessorAccess");
194 return string.IsNullOrEmpty (result
) ? GetManagedAccess () : result
;
197 public string GetDPManagedPropertyType (GlobalInfo all
)
199 string property_type
= Annotations
.GetValue ("ManagedPropertyType");
201 if (property_type
!= null)
202 return property_type
;
204 property_type
= Annotations
.GetValue ("PropertyType");
206 if (property_type
== null)
209 switch (property_type
) {
211 property_type
= "string"; break;
213 property_type
= "int"; break;
215 property_type
= "object"; break;
219 return "Nullable<" + property_type
+ ">";
221 return property_type
;
224 public string GetDependencyPropertyName ()
226 return Name
.Substring (0, Name
.LastIndexOf ("Property"));