2 using System.Collections.Generic;
5 namespace Tizen.NUI.Binding
7 [ContentProperty("Platforms")]
8 internal class OnPlatform<T>
12 Platforms = new List<On>();
15 bool useLegacyFallback;
20 get { return android; }
23 useLegacyFallback = true;
35 useLegacyFallback = true;
44 get { return winPhone; }
47 useLegacyFallback = true;
56 get { return @default; }
64 public IList<On> Platforms { get; private set; }
66 #pragma warning disable RECS0108 // Warns about static fields in generic types
67 static readonly IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>();
68 #pragma warning restore RECS0108 // Warns about static fields in generic types
70 public static implicit operator T(OnPlatform<T> onPlatform)
72 foreach (var onPlat in onPlatform.Platforms)
74 if (onPlat.Platform == null)
76 if (null != Device.RuntimePlatform && !onPlat.Platform.Contains(Device.RuntimePlatform))
78 if (s_valueConverter == null)
80 return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null);
83 if (!onPlatform.useLegacyFallback)
84 return onPlatform.hasDefault ? onPlatform.@default : default(T);
87 #pragma warning disable 0618, 0612
88 return Device.OnPlatform(iOS: onPlatform.iOS, Android: onPlatform.Android, WinPhone: onPlatform.WinPhone);
89 #pragma warning restore 0618, 0612
93 [ContentProperty("Value")]
96 [TypeConverter(typeof(ListStringTypeConverter))]
97 public IList<string> Platform { get; set; }
98 public object Value { get; set; }