Core parts of Xamarin.Android are the bindings for the Android APIs. The Xamarin team focused a great deal in developing a consistent approach to creating the bindings so that a C# .NET developer would feel at home when using them. This has resulted in a number of key benefits as follows:
A complete set of design principles can be found on the Xamarin website; we have included only a few for discussion:
The JavaBean properties, the getter and setter methods, are transformed to C# properties, when appropriate. The following rules are used to determine when properties should be created:
The Android APIs follow the Java pattern for defining and hooking up event listeners. The C# developers are more familiar with using delegates and events, so the Android bindings attempt to facilitate this using the following rules:
listener
callback has a void return, an event is generated based on the EventHandler
delegatelistener
callback does not have a void return, a specific delegate is generated that supports the appropriate signatureThese events or properties are only created under the following conditions:
setOnClickListener
It is common in the Android APIs to see methods that accept or return an int
type that must be mapped to a constant to determine its meaning. When possible, the Xamarin team creates a .NET enumeration to replace the constants and adjusts the appropriate methods to work with the enumerations. This provides a significant productivity gain by being able to use IntelliSense from within the IDE as well as enhancing the type safety of the methods.
18.220.59.69