diff options
Diffstat (limited to 'Xamarin.Forms.Core/OnPlatform.cs')
-rw-r--r-- | Xamarin.Forms.Core/OnPlatform.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core/OnPlatform.cs b/Xamarin.Forms.Core/OnPlatform.cs new file mode 100644 index 00000000..b66167fa --- /dev/null +++ b/Xamarin.Forms.Core/OnPlatform.cs @@ -0,0 +1,27 @@ +namespace Xamarin.Forms +{ + public class OnPlatform<T> + { + public T Android { get; set; } + + public T iOS { get; set; } + + public T WinPhone { get; set; } + + public static implicit operator T(OnPlatform<T> onPlatform) + { + switch (Device.OS) + { + case TargetPlatform.iOS: + return onPlatform.iOS; + case TargetPlatform.Android: + return onPlatform.Android; + case TargetPlatform.Windows: + case TargetPlatform.WinPhone: + return onPlatform.WinPhone; + } + + return onPlatform.iOS; + } + } +}
\ No newline at end of file |