I am building a project that has both Android and iOS clients with MonoTouch and MonoDroid. A common business layer project contains common domain entities.
One of them has a need to store an Image, Name and Age. The image is not downloaded.
Is it possible to create a common object that holds the actual data for a PNG or JPG but that is somehow workable in both iOS and Android?
///Simplified customer
class Customer {
public Image???;
public string Name;
public Int Age;
}
Options:
stay with native platform specific code requires partial classes and linking
common class in Customer.cs – linked through projects I call this approach split-n-link
or link-n-split
public partial class Customer {
public string Name;
public Int Age;
}
delta class for monotouch in monotouch project
delta class for mono for android in m4a project
So, each project will contain Customer.cs One original/source and other link to it, which one depends on preferences or common-feature-denominator if dealing with Windows Phone (currently it has smallest set of features – better it is more restrictive).
Besides main/original/source Customer.cs file, there are 2 (3 if WP) deltas with platform
specific stuff. Remember partial classes are “additive” meaning You can add Attributes in different cs file and they apply, so in this delta class one can add platform specific Attributes and enable stuff like binding for iOS ad/or Android if needed. From Holisticware experience (Visual Studio centric 80%+, 20% or less on Mac) source project is Mono for Android, but it could be reverse…
With link-n-spilt one ends up basically with POCO + delta and this POCO can be used for targeting desktop platform (WF, WPF) where everything is easier: debugging, unit testing, etc.
And there is advantage that each project is compiled/build with configuration for that platform – so ig guys from Xamarin come up with some other bright idea for builds like size optimizations this should not affect projects – recompile and go!
HTH
mel