| trunk/Source/RemObjects.Script/Common.pas |
| 207 | 207 | begin |
| 208 | 208 | var lAttr := array of System.ComponentModel.DefaultPropertyAttribute(fInstance.Type.GetCustomAttributes(typeof(System.ComponentModel.DefaultPropertyAttribute), true)); |
| 209 | 209 | if Length(lAttr) = 0 then raise new RuntimeException(RemObjects.Script.Properties.Resources.eNoSuchFunction); |
| 210 | | result := BindCall('get_'+lATtr[0].Name, false, indexes); |
| 210 | result := BindCall('get_'+lAttr[0].Name, false, indexes); |
| 211 | 211 | end; |
| 212 | 212 | |
| 213 | 213 | method TypeWrapperMetaObject.BindGetMember(binder: GetMemberBinder): DynamicMetaObject; |
| 214 | 214 | begin |
| 215 | 215 | if Length(fInstance.Type.GetProperties(BindingFlags.Static or BindingFlags.Public) ) > 0 then |
| 216 | 216 | result := BindCall('get_'+binder.Name, binder.IgnoreCase, []) |
| 217 | | else |
| 218 | | result := BindCall(binder.Name, binder.IgnoreCase, []); |
| 217 | else begin |
| 218 | var res := fInstance.Binder.GetMember(MemberRequestKind.Get, typeof(fInstance.Type), binder.Name); |
| 219 | if (res = nil) or (res.Count = 0) then |
| 220 | res := fInstance.Binder.GetMember(MemberRequestKind.InvokeMember, typeof(fInstance.Type), binder.Name); |
| 221 | |
| 222 | result := new DynamicMetaObject(Expression.Constant(res), BindingRestrictions.Empty) |
| 223 | end; |
| 224 | if assigned(result) and result.Expression.Type.IsValueType then |
| 225 | result := new DynamicMetaObject(Expression.Convert(result.Expression, typeof(Object)), result.Restrictions); |
| 219 | 226 | end; |
| 220 | 227 | |
| 221 | 228 | method TypeWrapperMetaObject.BindInvokeMember(binder: InvokeMemberBinder; args: array of DynamicMetaObject): DynamicMetaObject; |
| ... | ... | |
| 268 | 275 | |
| 269 | 276 | method TypeWrapperMetaObject.BindSetMember(binder: SetMemberBinder; value: DynamicMetaObject): DynamicMetaObject; |
| 270 | 277 | begin |
| 271 | | if Length(fInstance.Type.GetProperties(BindingFlags.Static or BindingFlags.Public) ) > 0 then |
| 272 | | result := BindCall('set_'+binder.Name, binder.IgnoreCase, [value]) |
| 273 | | else |
| 274 | | result := BindCall(binder.Name, binder.IgnoreCase, [value]); |
| 278 | result := BindCall('set_'+binder.Name, binder.IgnoreCase, [value]); |
| 275 | 279 | end; |
| 276 | 280 | |
| 277 | 281 | end. |