summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core/OnPlatform.cs
blob: 71879a7d1e31554710478ce164459501d3e16290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace Xamarin.Forms
{
	public class OnPlatform<T>
	{
		public T Android { get; set; }

		public T iOS { get; set; }

		public T WinPhone { get; set; }

		public T Tizen { 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;
				case TargetPlatform.Tizen:
					return onPlatform.Tizen;
			}

			return onPlatform.iOS;
		}
	}
}