Because the content is dynamic and so is the property getter.

On 14 August 2012 16:18, Jonathan Pryor <j...@xamarin.com> wrote:

> On Aug 14, 2012, at 6:15 AM, Goncalo Oliveira <gonc...@minkan.net> wrote:
> > The thing is... this is kind of unusable. The whole reason I'm using
> reflection is because I don't know which properties I might need.
>
> I don't understand this; why is Reflection preferable to using type
> checking? Why wouldn't you know which properties you need?
>
>         static int GetSelectedItemPosition (object value)
>         {
>                 var v = value as AdapterView;   // base class of Spinner
>                 if (s != null)
>                         return v.SelectedItemPosition;
>                 var a = value as ListActivity;
>                 if (a != null)
>                         return a.SelectedItemPosition;
> #if __ANDROID_11__
>                 var w = value as ListPopupWindow;
>                 if (w != null)
>                         return w.SelectedItemPosition;
>                 var f = value as ListFragment;
>                 if (f != null)
>                         return f.SelectedItemPosition;
> #endif  // __ANDROID_11__
>                 // check other types as necessary
>                 throw new NotSupportedException ("Cannot get
> SelectedItemPosition from " + value.GetType ().FullName);
>         }
>
>  - Jon
>
> _______________________________________________
> Monodroid mailing list
> Monodroid@lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>



-- 
Gonçalo Oliveira
_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to