diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-01-12 21:05:41 +0100 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2017-01-12 12:05:41 -0800 |
commit | b6cb64e4930de9b16309f2d30c6bb0a2177048fd (patch) | |
tree | ae15f36d3e0e60cac6305f90520ad778de9c6ee3 | |
parent | 3af99cbbe145a876cc9839af0adead83695b5445 (diff) | |
download | xamarin-forms-b6cb64e4930de9b16309f2d30c6bb0a2177048fd.tar.gz xamarin-forms-b6cb64e4930de9b16309f2d30c6bb0a2177048fd.tar.bz2 xamarin-forms-b6cb64e4930de9b16309f2d30c6bb0a2177048fd.zip |
[C] new OnPlatform mechanism (#658)
* [C] Obsolete TargetPlatform
* [Xaml] support and test the new syntax
* blind fix windows platforms
71 files changed, 598 insertions, 277 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla22229.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla22229.xaml.cs index 1ddf4e4e..f7d8918c 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla22229.xaml.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla22229.xaml.cs @@ -19,11 +19,18 @@ namespace Xamarin.Forms.Controls public Bugzilla22229() { InitializeComponent(); - _prefix = Device.OnPlatform( - iOS: "Images/", - Android: "", - WinPhone: "Assets/" - ); + switch (Device.RuntimePlatform) { + case Device.iOS: + _prefix = "Images/"; + break; + case Device.Android: + _prefix = ""; + break; + case Device.Windows: + case Device.WinPhone: + _prefix = "Assets/"; + break; + } InitializeActionBar(); } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26868.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26868.cs index 000b30ab..a08799fe 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26868.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla26868.cs @@ -30,9 +30,9 @@ namespace Xamarin.Forms.Controls var listView = new ListView { IsGroupingEnabled = true, - GroupDisplayBinding = new Binding ("GroupName"), - GroupShortNameBinding = new Binding ("GroupName"), - HasUnevenRows = Device.OnPlatform (Android: true, WinPhone: false, iOS: false), + GroupDisplayBinding = new Binding("GroupName"), + GroupShortNameBinding = new Binding("GroupName"), + HasUnevenRows = Device.RuntimePlatform == Device.Android, ItemTemplate = itemTemplate, GroupHeaderTemplate = groupHeaderTemplate, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla34632.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla34632.cs index bf26bdb1..30cbc5a8 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla34632.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla34632.cs @@ -16,7 +16,7 @@ namespace Xamarin.Forms.Controls.Issues { protected override void Init () { - if (Device.OS == TargetPlatform.Windows) + if (Device.RuntimePlatform == Device.Windows) MasterBehavior = MasterBehavior.Split; else MasterBehavior = MasterBehavior.SplitOnLandscape; diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs index 7abfa5d3..d4de5aa3 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla42069.cs @@ -19,11 +19,16 @@ namespace Xamarin.Forms.Controls if (!Application.Current.Resources.ContainsKey("SomeSmallImage")) { - var smallImage = new OnPlatform<ImageSource> { - Android = ImageSource.FromFile("coffee.png"), - WinPhone = ImageSource.FromFile("bank.png"), - iOS = ImageSource.FromFile("coffee.png") - }; + ImageSource smallImage; + switch (Device.RuntimePlatform) { + default: + smallImage = "coffee.png"; + break; + case Device.WinPhone: + case Device.Windows: + smallImage = "bank.png"; + break; + } Application.Current.Resources.Add("SomeSmallImage", smallImage); } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/DefaultColorToggleTest.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/DefaultColorToggleTest.cs index f943f158..7cfbca89 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/DefaultColorToggleTest.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/DefaultColorToggleTest.cs @@ -324,7 +324,7 @@ namespace Xamarin.Forms.Controls return new ContentPage { Title = "TimePicker", - Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, Device.OnPlatform(00, 0, 0)), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), Content = new StackLayout { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, @@ -389,7 +389,7 @@ namespace Xamarin.Forms.Controls return new ContentPage { Title = "DatePicker", - Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, Device.OnPlatform(00, 0, 0)), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), Content = new StackLayout { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, @@ -457,7 +457,7 @@ namespace Xamarin.Forms.Controls return new ContentPage { Title = "Picker", - Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, Device.OnPlatform(00, 0, 0)), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), Content = new StackLayout { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ImageLoadingErrorHandling.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ImageLoadingErrorHandling.cs index fe1f6356..6abac885 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ImageLoadingErrorHandling.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/ImageLoadingErrorHandling.cs @@ -31,7 +31,7 @@ namespace Xamarin.Forms.Controls Grid fakeUri = CreateTest(() => image.Source = ImageSource.FromUri(new Uri("http://not.real")), "Non-existent URI", - Device.OS == TargetPlatform.Windows && Device.Idiom == TargetIdiom.Phone + Device.RuntimePlatform == Device.Windows && Device.Idiom == TargetIdiom.Phone ? "Clicking this button should display an alert dialog. The error message should include the text 'NotFound'." : "Clicking this button should display an alert dialog. The error message should include the text 'the server name or address could not be resolved'."); diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs index ff1b86d8..2943e680 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1075.cs @@ -77,7 +77,7 @@ namespace Xamarin.Forms.Controls }; // Accomodate iPhone status bar. - Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 0); + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 0) : new Thickness(10, 0); // Build the page. Content = new StackLayout diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1461.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1461.cs index 6c5bfc35..1cb583ae 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1461.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1461.cs @@ -220,7 +220,7 @@ namespace Xamarin.Forms.Controls.Issues Master = new ContentPage { Title = string.Format ("Master sample for {0}", state), Icon = "bank.png", - Padding = Device.OnPlatform (new Thickness (5, 60, 5, 5), 5, 5), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(5, 60, 5, 5) : new Thickness(5), Content = new StackLayout { Children = { new Label { diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1769.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1769.cs index 3f12a08b..4fa4e6f6 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1769.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue1769.cs @@ -63,7 +63,7 @@ namespace Xamarin.Forms.Controls }; // Accomodate iPhone status bar. - Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5); // Build the page. Content = new StackLayout diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue194.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue194.cs index a3a75c8a..e7bfaa62 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue194.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue194.cs @@ -47,7 +47,7 @@ namespace Xamarin.Forms.Controls Title = "Page 9" }; - Device.OnPlatform (iOS: () => { + if (Device.RuntimePlatform == Device.iOS) { // Create an overflow amount of tabs depending on device if (Device.Idiom == TargetIdiom.Tablet) { Children.Add (pageOne); @@ -67,7 +67,7 @@ namespace Xamarin.Forms.Controls Children.Add (pageFive); Children.Add (pageSix); } - }); + } } } } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2259.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2259.cs index d59ef24f..7f129406 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2259.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2259.cs @@ -130,7 +130,7 @@ namespace Xamarin.Forms.Controls.Issues listView.ScrollTo (person, ScrollToPosition.End, true); }; - Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5); + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5); Content = new StackLayout { Orientation = StackOrientation.Vertical, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2357.xaml.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2357.xaml.cs index 1a249f7a..edb609ad 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2357.xaml.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2357.xaml.cs @@ -138,7 +138,7 @@ namespace Xamarin.Forms.Controls static void WebView_OnNavigating (object sender, WebNavigatingEventArgs e) { - Debug.WriteLine ("OS: " + Device.OS + " Current Url: " + GetSourceUrl (((WebView)sender).Source) + "Destination Url: " + e.Url + " " + DateTime.Now); + Debug.WriteLine ("OS: " + Device.RuntimePlatform + " Current Url: " + GetSourceUrl (((WebView)sender).Source) + "Destination Url: " + e.Url + " " + DateTime.Now); if (e.Url.IsValidAbsoluteUrl ()) { var destinationUri = new Uri (e.Url); diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2597.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2597.cs index 4f39c33c..59eccfc5 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2597.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2597.cs @@ -40,8 +40,7 @@ namespace Xamarin.Forms.Controls }; // Accomodate iPhone status bar. - Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, - 5); + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5); // Build the page. Content = new StackLayout diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2634.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2634.cs index b2cf7390..e6a9b6f9 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2634.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2634.cs @@ -235,12 +235,10 @@ namespace Xamarin.Forms.Controls Forms.Constraint.RelativeToParent ((parent) => parent.Height)); - rl.Children.Add (addFrame, - Forms.Constraint.RelativeToParent ((parent) => - (parent.Width * .25) / 2), - Forms.Constraint.Constant (Device.OnPlatform (60, 40, 40)), - Forms.Constraint.RelativeToParent ((parent) => - parent.Width * .75)); + rl.Children.Add(addFrame, + Forms.Constraint.RelativeToParent((parent) => (parent.Width * .25) / 2), + Forms.Constraint.Constant(Device.RuntimePlatform == Device.iOS ? 60 : 40), + Forms.Constraint.RelativeToParent((parent) => parent.Width * .75)); Content = rl; } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2961.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2961.cs index a0e2772a..8836d610 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2961.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2961.cs @@ -144,7 +144,7 @@ namespace Xamarin.Forms.Controls.Issues Children = { logoImg } }; - var paddingTop = Device.OnPlatform (40, 2, 2); + var paddingTop = Device.RuntimePlatform == Device.iOS ? 40 : 2; Content = new StackLayout { Spacing = 0, BackgroundColor = Color.FromHex ("1e1e1e"), diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2976.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2976.cs index 7e903141..b145d9de 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2976.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2976.cs @@ -73,15 +73,15 @@ namespace Xamarin.Forms.Controls.Issues // The root page of your application Content = new StackLayout { - Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), Children = { new Label { #pragma warning disable 618 XAlign = TextAlignment.Center, #pragma warning restore 618 - Text = Device.OnPlatform("Custom renderer UITableView","Custom renderer ListView","Custom renderer todo") + Text = Device.RuntimePlatform == Device.iOS ? "Custom renderer UITableView" : Device.RuntimePlatform == Device.Android ? "Custom renderer ListView" : "Custom renderer todo" }, - fasterListView + fasterListView } }; } @@ -143,7 +143,7 @@ namespace Xamarin.Forms.Controls.Issues }; Content = new StackLayout { - Padding = new Thickness (5, Device.OnPlatform(20,0,0), 5, 0), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(5, 20, 5, 0) : new Thickness(5,0), Children = { new Label { #pragma warning disable 618 @@ -185,7 +185,7 @@ namespace Xamarin.Forms.Controls.Issues }; Content = new StackLayout { - Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), Children = { new Label { #pragma warning disable 618 @@ -250,7 +250,7 @@ namespace Xamarin.Forms.Controls.Issues b.Clicked += (sender, e) => Navigation.PopModalAsync(); Content = new StackLayout { - Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, Children = { @@ -289,13 +289,13 @@ namespace Xamarin.Forms.Controls.Issues // The root page of your application Content = new StackLayout { - Padding = new Thickness (0, Device.OnPlatform(20,0,0), 0, 0), + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(0, 20, 0, 0) : new Thickness(0), Children = { new Label { #pragma warning disable 618 XAlign = TextAlignment.Center, #pragma warning restore 618 - Text = Device.OnPlatform("Custom UITableView+UICell","Custom ListView+Cell","Custom renderer todo") + Text = Device.RuntimePlatform == Device.iOS ? "Custom UITableView+UICell" : Device.RuntimePlatform == Device.Android ? "Custom ListView+Cell" : "Custom renderer todo" }, nativeListView2 } diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2987.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2987.cs index 785bcda9..8a6ce08f 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2987.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2987.cs @@ -22,7 +22,7 @@ namespace Xamarin.Forms.Controls Debug.WriteLine ("Date changed"); }; - Padding = new Thickness (10, Device.OnPlatform (20, 0, 0), 10, 5); + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5); layout = new AbsoluteLayout { VerticalOptions = LayoutOptions.FillAndExpand, diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue773.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue773.cs index f8c22337..63d9cbc1 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue773.cs +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue773.cs @@ -162,10 +162,10 @@ namespace Xamarin.Forms.Controls.Issues layout.Children.Add (label); - layout.Children.Add (new ScrollView { + layout.Children.Add(new ScrollView { BackgroundColor = Color.Aqua, Orientation = ScrollOrientation.Horizontal, - HeightRequest = Device.OnPlatform (44, 44, 80), + HeightRequest = Device.RuntimePlatform == Device.Windows || Device.RuntimePlatform == Device.WinPhone ? 80 : 44, Content = buttonStack }); diff --git a/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs index 23a2035a..4c588ab9 100644 --- a/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/AbsoluteLayoutGallery.cs @@ -87,11 +87,8 @@ namespace Xamarin.Forms.Controls { public AbsoluteLayoutGallery () { - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); BindingContext = new AbsolutePositioningExplorationViewModel (); var absLayout = new AbsoluteLayout { diff --git a/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs b/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs index 0558b192..896085a3 100644 --- a/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/ButtonGallery.cs @@ -31,8 +31,21 @@ namespace Xamarin.Forms.Controls var click = new Button { Text = "Click Button" }; var rotate = new Button { Text = "Rotate Button" }; var transparent = new Button { Text = "Transparent Button" }; + string fontName; + switch (Device.RuntimePlatform) { + default: + case Device.iOS: + fontName = "Georgia"; + break; + case Device.Android: + fontName = "sans-serif-light"; + break; + case Device.WinPhone: + case Device.Windows: + fontName = "Comic Sans MS"; + break; + } - var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS"); var font = Font.OfSize (fontName, NamedSize.Medium); var themedButton = new Button { diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs index 89740fb5..0a9c21b4 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellListPage.cs @@ -18,11 +18,8 @@ namespace Xamarin.Forms.Controls { Title = "EntryCell List Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var dataTemplate = new DataTemplate (typeof(EntryCell)); dataTemplate.SetBinding (EntryCell.LabelProperty, new Binding ("Label")); diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs index c37dd441..f3fe5e57 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/EntryCellTablePage.cs @@ -6,11 +6,8 @@ namespace Xamarin.Forms.Controls { Title = "EntryCell Table Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); int timesEntered = 1; diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs index 62ec6940..1071505c 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellListPage.cs @@ -21,11 +21,8 @@ namespace Xamarin.Forms.Controls { Title = "ImageCell List Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var dataTemplate = new DataTemplate (typeof (ImageCell)); var stringToImageSourceConverter = new GenericValueConverter ( @@ -73,11 +70,8 @@ namespace Xamarin.Forms.Controls { public UrlImageCellListPage() { - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var dataTemplate = new DataTemplate (typeof (ImageCell)); var stringToImageSourceConverter = new GenericValueConverter ( diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs index 2b941bfd..988c8a7f 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ImageCellTablePage.cs @@ -7,11 +7,8 @@ namespace Xamarin.Forms.Controls { Title = "ImageCell Table Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var tableSection = new TableSection ("Section One") { new ImageCell { Text = "Text 1", ImageSource = new FileImageSource { File = "crimson.jpg" } }, diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs index 5973ebab..e0b4b9df 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ProductViewCell.cs @@ -20,7 +20,7 @@ namespace Xamarin.Forms.Controls var frame = new Frame { Content = _stack, - BackgroundColor = Device.OnPlatform (iOS: new Color (1), Android: new Color (0.2), WinPhone: new Color (0.2)) + BackgroundColor = new[] { Device.Android, Device.Windows, Device.WinPhone }.Contains(Device.RuntimePlatform) ? new Color(0.2) : new Color(1) }; _timeLabel = new Label { Text = text diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs index 799d6989..0d336b34 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellListPage.cs @@ -16,11 +16,8 @@ namespace Xamarin.Forms.Controls { Title = "SwitchCell List Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var dataTemplate = new DataTemplate (typeof (SwitchCell)) { Bindings = { diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs index a0deb8e6..5a92ed4b 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/SwitchCellTablePage.cs @@ -6,11 +6,8 @@ namespace Xamarin.Forms.Controls { Title = "SwitchCell Table Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var tableSection = new TableSection ("Section One") { new SwitchCell { Text = "text 1", On = true }, diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs index 2b2761e7..e2f071b6 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellListPage.cs @@ -17,11 +17,8 @@ namespace Xamarin.Forms.Controls { Title = "TextCell List Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var label = new Label { Text = "Not Selected" }; diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs index b9cc0cf3..fa1697b1 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/TextCellTablePage.cs @@ -7,11 +7,8 @@ namespace Xamarin.Forms.Controls { Title = "TextCell Table Gallery - Legacy"; - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var tableSection = new TableSection ("Section One") { new TextCell { Text = "Text 1" }, diff --git a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs index 099a786a..f256abeb 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/CellsGalleries/ViewCellGallery.cs @@ -31,11 +31,8 @@ namespace Xamarin.Forms.Controls { public UrlImageViewCellListPage() { - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var stringToImageSourceConverter = new GenericValueConverter ( obj => new UriImageSource() { diff --git a/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs b/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs index ee7c1822..653ecdae 100644 --- a/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/FrameGallery.cs @@ -22,7 +22,7 @@ namespace Xamarin.Forms.Controls Content = new Button { Text = "Framous!" }, - BackgroundColor = Device.OnPlatform (iOS: new Color (1), Android: new Color (0), WinPhone: new Color (0)), + BackgroundColor = new[] { Device.Android, Device.Windows, Device.WinPhone }.Contains(Device.RuntimePlatform) ? new Color(0) : new Color(1), VerticalOptions = LayoutOptions.FillAndExpand }; diff --git a/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs b/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs index c40d7ae4..4ae44ba6 100644 --- a/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/LabelGallery.cs @@ -72,8 +72,20 @@ namespace Xamarin.Forms.Controls #pragma warning disable 618 bolditalic.Font = Font.SystemFontOfSize (NamedSize.Medium, FontAttributes.Bold | FontAttributes.Italic); #pragma warning restore 618 - - var fontName = Device.OnPlatform ("Georgia", "sans-serif-light", "Comic Sans MS"); + string fontName; + switch (Device.RuntimePlatform) { + default: + case Device.iOS: + fontName = "Georgia"; + break; + case Device.Android: + fontName = "sans-serif-light"; + break; + case Device.WinPhone: + case Device.Windows: + fontName = "Comic Sans MS"; + break; + } var font = Font.OfSize (fontName, NamedSize.Medium); #pragma warning disable 618 customFont.Font = font; @@ -113,10 +125,8 @@ namespace Xamarin.Forms.Controls Thickness padding = new Thickness (20); // Padding Adjust for iPad - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) - padding = new Thickness (20, 20, 20, 60); - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(20, 20, 20, 60); Content = new ScrollView { Content = new StackLayout { diff --git a/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs b/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs index 370fb6d9..efbc57cf 100644 --- a/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs +++ b/Xamarin.Forms.Controls/GalleryPages/ListViewDemoPage.cs @@ -225,8 +225,7 @@ namespace Xamarin.Forms.Controls }; // Accomodate iPhone status bar. - Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5); - + Padding = Device.RuntimePlatform == Device.iOS ? new Thickness(10, 20, 10, 5) : new Thickness(10, 0, 10, 5); // Build the page. Content = new StackLayout { diff --git a/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs b/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs index dd283c3a..0488cc27 100644 --- a/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/MapGallery.cs @@ -14,11 +14,8 @@ namespace Xamarin.Forms.Controls public MapGallery () { - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var map = MakeMap (); diff --git a/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs b/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs index b08b5f35..7a985653 100644 --- a/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs +++ b/Xamarin.Forms.Controls/GalleryPages/StackLayoutGallery.cs @@ -10,11 +10,8 @@ namespace Xamarin.Forms.Controls { public StackLayoutGallery () { - Device.OnPlatform (iOS: () => { - if (Device.Idiom == TargetIdiom.Tablet) { - Padding = new Thickness (0, 0, 0, 60); - } - }); + if (Device.RuntimePlatform == Device.iOS && Device.Idiom == TargetIdiom.Tablet) + Padding = new Thickness(0, 0, 0, 60); var stack = new StackLayout { Orientation = StackOrientation.Vertical }; Button b1 = new Button { Text = "Boring", HeightRequest = 500, MinimumHeightRequest = 50 }; diff --git a/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs b/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs index 40e488e4..6568dca7 100644 --- a/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs +++ b/Xamarin.Forms.Controls/HanselForms/TwitterPage.xaml.cs @@ -119,11 +119,11 @@ namespace Xamarin.Forms.Controls // Tweets.Add(tweet); //} - if (Device.OS == TargetPlatform.iOS) - { - // only does anything on iOS, for the Watch - // DependencyService.Get<ITweetStore>().Save(tweets); - } + //if (Device.OS == TargetPlatform.iOS) + //{ + // // only does anything on iOS, for the Watch + // // DependencyService.Get<ITweetStore>().Save(tweets); + //} diff --git a/Xamarin.Forms.Controls/TestCases.cs b/Xamarin.Forms.Controls/TestCases.cs index fc601024..d05b0a0e 100644 --- a/Xamarin.Forms.Controls/TestCases.cs +++ b/Xamarin.Forms.Controls/TestCases.cs @@ -204,9 +204,19 @@ namespace Xamarin.Forms.Controls rootLayout.Children.Add (searchButton); rootLayout.Children.Add (new TestCaseScreen ()); - return new NavigationPage (testCasesRoot) { - Title = Device.OnPlatform ("Test Cases", "Test Cases", "Tests") - }; + var page = new NavigationPage(testCasesRoot); + switch (Device.RuntimePlatform) { + case Device.iOS: + case Device.Android: + default: + page.Title = "Test Cases"; + break; + case Device.WinPhone: + case Device.Windows: + page.Title = "Tests"; + break; + } + return page; } } diff --git a/Xamarin.Forms.Core.UnitTests/DataTemplateSelectorTests.cs b/Xamarin.Forms.Core.UnitTests/DataTemplateSelectorTests.cs index 85779956..552f784b 100644 --- a/Xamarin.Forms.Core.UnitTests/DataTemplateSelectorTests.cs +++ b/Xamarin.Forms.Core.UnitTests/DataTemplateSelectorTests.cs @@ -7,6 +7,20 @@ namespace Xamarin.Forms.Core.UnitTests [TestFixture] public class DataTemplateSelectorTests : BaseTestFixture { + [TearDown] + public override void TearDown() + { + base.TearDown(); + Device.PlatformServices = null; + } + + [SetUp] + public override void Setup() + { + base.Setup(); + Device.PlatformServices = new MockPlatformServices(); + } + class TemplateOne : DataTemplate { public TemplateOne () : base (typeof (ViewCell)) diff --git a/Xamarin.Forms.Core.UnitTests/ListViewTests.cs b/Xamarin.Forms.Core.UnitTests/ListViewTests.cs index b373696a..329ba86c 100644 --- a/Xamarin.Forms.Core.UnitTests/ListViewTests.cs +++ b/Xamarin.Forms.Core.UnitTests/ListViewTests.cs @@ -1472,20 +1472,20 @@ namespace Xamarin.Forms.Core.UnitTests Assert.That (cell.Parent, Is.Null); } - [TestCase (TargetPlatform.Android, ListViewCachingStrategy.RecycleElement)] - [TestCase (TargetPlatform.iOS, ListViewCachingStrategy.RecycleElement)] - [TestCase (TargetPlatform.Windows, ListViewCachingStrategy.RetainElement)] - [TestCase (TargetPlatform.Other, ListViewCachingStrategy.RetainElement)] - [TestCase (TargetPlatform.WinPhone, ListViewCachingStrategy.RetainElement)] - public void EnforcesCachingStrategy (TargetPlatform platform, ListViewCachingStrategy expected) - { - var oldOS = Device.OS; + [TestCase (Device.Android, ListViewCachingStrategy.RecycleElement)] + [TestCase (Device.iOS, ListViewCachingStrategy.RecycleElement)] + [TestCase (Device.Windows, ListViewCachingStrategy.RetainElement)] + [TestCase ("Other", ListViewCachingStrategy.RetainElement)] + [TestCase (Device.WinPhone, ListViewCachingStrategy.RetainElement)] + public void EnforcesCachingStrategy (string platform, ListViewCachingStrategy expected) + { + var oldOS = Device.RuntimePlatform; // we need to do this because otherwise we cant set the caching strategy - Device.OS = platform; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = platform; var listView = new ListView (ListViewCachingStrategy.RecycleElement); Assert.AreEqual (expected, listView.CachingStrategy); - Device.OS = oldOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = oldOS; } [Test] @@ -1504,9 +1504,9 @@ namespace Xamarin.Forms.Core.UnitTests "Bar" }; - var oldOS = Device.OS; + var oldOS = Device.RuntimePlatform; // we need to do this because otherwise we cant set the caching strategy - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; var bindable = new ListView (ListViewCachingStrategy.RecycleElement); bindable.ItemTemplate = new DataTemplate (typeof (TextCell)) { @@ -1521,7 +1521,7 @@ namespace Xamarin.Forms.Core.UnitTests Assert.False(ReferenceEquals (item1, item2)); - Device.OS = oldOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = oldOS; } } } diff --git a/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs b/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs index e8519b9e..3d6ddb92 100644 --- a/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs +++ b/Xamarin.Forms.Core.UnitTests/MockPlatformServices.cs @@ -82,6 +82,8 @@ namespace Xamarin.Forms.Core.UnitTests get { return false; } } + public string RuntimePlatform { get; set; } + public void BeginInvokeOnMainThread (Action action) { if (invokeOnMainThread == null) diff --git a/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs b/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs index 9e7f0546..3bea3725 100644 --- a/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs +++ b/Xamarin.Forms.Core.UnitTests/ViewUnitTests.cs @@ -103,7 +103,7 @@ namespace Xamarin.Forms.Core.UnitTests bool android = false; bool winphone = false; - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; Device.OnPlatform ( iOS: () => ios = true, @@ -124,7 +124,7 @@ namespace Xamarin.Forms.Core.UnitTests bool android = false; bool winphone = false; - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; Device.OnPlatform ( iOS: () => ios = true, @@ -145,7 +145,7 @@ namespace Xamarin.Forms.Core.UnitTests bool android = false; bool winphone = false; - Device.OS = TargetPlatform.WinPhone; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.WinPhone; Device.OnPlatform ( iOS: () => ios = true, @@ -165,7 +165,7 @@ namespace Xamarin.Forms.Core.UnitTests bool ios = false; bool android = false; - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; Device.OnPlatform ( iOS: () => ios = false, @@ -179,7 +179,7 @@ namespace Xamarin.Forms.Core.UnitTests public void TestOnPlatformNoOpWithoutDefault () { bool any = false; - Device.OS = TargetPlatform.Other; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = "Other"; Device.OnPlatform ( iOS: () => any = true, @@ -194,7 +194,7 @@ namespace Xamarin.Forms.Core.UnitTests { bool defaultExecuted = false; - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; Device.OnPlatform ( Android: () => { }, @@ -209,7 +209,7 @@ namespace Xamarin.Forms.Core.UnitTests { bool defaultExecuted = false; - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; Device.OnPlatform ( iOS: () => { }, @@ -224,7 +224,7 @@ namespace Xamarin.Forms.Core.UnitTests { bool defaultExecuted = false; - Device.OS = TargetPlatform.WinPhone; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.WinPhone; Device.OnPlatform ( iOS: () => { }, @@ -239,7 +239,7 @@ namespace Xamarin.Forms.Core.UnitTests { bool defaultExecuted = false; - Device.OS = TargetPlatform.Other; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = "Other"; Device.OnPlatform ( iOS: () => { }, @@ -432,16 +432,16 @@ namespace Xamarin.Forms.Core.UnitTests [Test] public void TestOnPlatformGeneric () { - Device.OS = TargetPlatform.WinPhone; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.WinPhone; Assert.AreEqual (3, Device.OnPlatform (1, 2, 3)); - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; Assert.AreEqual (1, Device.OnPlatform (1, 2, 3)); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; Assert.AreEqual (2, Device.OnPlatform (1, 2, 3)); - Device.OS = TargetPlatform.Other; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = "Other"; Assert.AreEqual (1, Device.OnPlatform (1, 2, 3)); } diff --git a/Xamarin.Forms.Core/Device.cs b/Xamarin.Forms.Core/Device.cs index 5a02bcea..f18251d2 100644 --- a/Xamarin.Forms.Core/Device.cs +++ b/Xamarin.Forms.Core/Device.cs @@ -8,13 +8,30 @@ namespace Xamarin.Forms { public static class Device { + public const string iOS = "iOS"; + public const string Android = "Android"; + public const string WinPhone = "WinPhone"; + public const string Windows = "Windows"; + internal static DeviceInfo info; static IPlatformServices s_platformServices; public static TargetIdiom Idiom { get; internal set; } - public static TargetPlatform OS { get; internal set; } + [Obsolete("Use RuntimePlatform instead.")] +#pragma warning disable 0618 + public static TargetPlatform OS { + get { + TargetPlatform platform; + if (Enum.TryParse(RuntimePlatform, out platform)) + return platform; + return TargetPlatform.Other; + } + } +#pragma warning restore 0618 + + public static string RuntimePlatform => PlatformServices.RuntimePlatform; internal static DeviceInfo Info { @@ -58,6 +75,7 @@ namespace Xamarin.Forms return GetNamedSize(size, targetElementType, false); } + [Obsolete("Use switch(RuntimePlatform) instead.")] public static void OnPlatform(Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null) { switch (OS) @@ -88,6 +106,7 @@ namespace Xamarin.Forms } } + [Obsolete("Use switch(RuntimePlatform) instead.")] public static T OnPlatform<T>(T iOS, T Android, T WinPhone) { switch (OS) @@ -104,18 +123,6 @@ namespace Xamarin.Forms return iOS; } - public static T OnPlatform<T>(T iOS, T Android, T WinPhone, T Tizen) - { - if (OS == TargetPlatform.Tizen) - { - return Tizen; - } - else - { - return OnPlatform<T>(iOS, Android, WinPhone); - } - } - public static void OpenUri(Uri uri) { PlatformServices.OpenUriAction(uri); diff --git a/Xamarin.Forms.Core/IPlatformServices.cs b/Xamarin.Forms.Core/IPlatformServices.cs index a01baa02..39f00731 100644 --- a/Xamarin.Forms.Core/IPlatformServices.cs +++ b/Xamarin.Forms.Core/IPlatformServices.cs @@ -28,5 +28,7 @@ namespace Xamarin.Forms void OpenUriAction(Uri uri); void StartTimer(TimeSpan interval, Func<bool> callback); + + string RuntimePlatform { get; } } }
\ No newline at end of file diff --git a/Xamarin.Forms.Core/ListView.cs b/Xamarin.Forms.Core/ListView.cs index 8b4fc53d..0751e1c2 100644 --- a/Xamarin.Forms.Core/ListView.cs +++ b/Xamarin.Forms.Core/ListView.cs @@ -71,7 +71,7 @@ namespace Xamarin.Forms public ListView([Parameter("CachingStrategy")] ListViewCachingStrategy cachingStrategy) : this() { - if (Device.OS == TargetPlatform.Android || Device.OS == TargetPlatform.iOS) + if (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.iOS) CachingStrategy = cachingStrategy; } diff --git a/Xamarin.Forms.Core/OnPlatform.cs b/Xamarin.Forms.Core/OnPlatform.cs index 02e27083..68621134 100644 --- a/Xamarin.Forms.Core/OnPlatform.cs +++ b/Xamarin.Forms.Core/OnPlatform.cs @@ -1,16 +1,79 @@ +using System; +using System.Collections.Generic; +using Xamarin.Forms.Xaml; + namespace Xamarin.Forms { + [ContentProperty("Platforms")] public class OnPlatform<T> { - public T Android { get; set; } - public T iOS { get; set; } - public T WinPhone { get; set; } + public OnPlatform() + { + Platforms = new List<On>(); + } + + bool useLegacyFallback; + T android; + [Obsolete] + public T Android { + get { return android; } + set { + useLegacyFallback = true; + android = value; + } + } + + T ios; + [Obsolete] + public T iOS { + get { return ios; } + set { + useLegacyFallback = true; + ios = value; + } + } - public T Tizen { get; set; } + T winPhone; + [Obsolete] + public T WinPhone { + get { return winPhone; } + set { + useLegacyFallback = true; + winPhone = value; + } + } + + public IList<On> Platforms { get; private set; } + + static readonly IValueConverterProvider s_valueConverter = DependencyService.Get<IValueConverterProvider>(); public static implicit operator T(OnPlatform<T> onPlatform) { - return Device.OnPlatform(iOS: onPlatform.iOS, Android: onPlatform.Android, WinPhone: onPlatform.WinPhone, Tizen: onPlatform.Tizen); + foreach (var onPlat in onPlatform.Platforms) { + if (onPlat.Platform == null) + continue; + if (!onPlat.Platform.Contains(Device.RuntimePlatform)) + continue; + if (s_valueConverter == null) + continue; + return (T)s_valueConverter.Convert(onPlat.Value, typeof(T), null, null); + } + + if (!onPlatform.useLegacyFallback) + return default(T); + + //legacy fallback +#pragma warning disable 0618, 0612 + return Device.OnPlatform(iOS: onPlatform.iOS, Android: onPlatform.Android, WinPhone: onPlatform.WinPhone); +#pragma warning restore 0618, 0612 } } -}
\ No newline at end of file + + [ContentProperty("Value")] + public class On + { + [TypeConverter(typeof(ListStringTypeConverter))] + public IList<string> Platform { get; set; } + public object Value { get; set; } + } +} diff --git a/Xamarin.Forms.Core/TargetPlatform.cs b/Xamarin.Forms.Core/TargetPlatform.cs index 62fbda09..6125695f 100644 --- a/Xamarin.Forms.Core/TargetPlatform.cs +++ b/Xamarin.Forms.Core/TargetPlatform.cs @@ -1,5 +1,8 @@ +using System; + namespace Xamarin.Forms { + [Obsolete] public enum TargetPlatform { Other, @@ -7,6 +10,5 @@ namespace Xamarin.Forms Android, WinPhone, Windows, - Tizen } } diff --git a/Xamarin.Forms.Core/TemplatedItemsList.cs b/Xamarin.Forms.Core/TemplatedItemsList.cs index cb64e2e9..a954939d 100644 --- a/Xamarin.Forms.Core/TemplatedItemsList.cs +++ b/Xamarin.Forms.Core/TemplatedItemsList.cs @@ -970,7 +970,7 @@ namespace Xamarin.Forms /* HACKAHACKHACK: LongListSelector on WP SL has a bug in that it completely fails to deal with * INCC notifications that include more than 1 item. */ - if (fixWindows && Device.OS == TargetPlatform.WinPhone) + if (fixWindows && Device.RuntimePlatform == Device.WinPhone) { SplitCollectionChangedItems(e); return; @@ -1205,7 +1205,7 @@ namespace Xamarin.Forms //Hack: the cell could still be visible on iOS because the cells are reloaded after this unhook //this causes some visual updates caused by a null datacontext and default values like IsVisible - if (Device.OS == TargetPlatform.iOS && CachingStrategy == ListViewCachingStrategy.RetainElement) + if (Device.RuntimePlatform == Device.iOS && CachingStrategy == ListViewCachingStrategy.RetainElement) await Task.Delay(100); item.BindingContext = null; } diff --git a/Xamarin.Forms.Platform.Android/Forms.cs b/Xamarin.Forms.Platform.Android/Forms.cs index 3183c109..c2352359 100644 --- a/Xamarin.Forms.Platform.Android/Forms.cs +++ b/Xamarin.Forms.Platform.Android/Forms.cs @@ -120,7 +120,6 @@ namespace Xamarin.Forms if (!IsInitialized) Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); - Device.OS = TargetPlatform.Android; Device.PlatformServices = new AndroidPlatformServices(); // use field and not property to avoid exception in getter @@ -408,6 +407,8 @@ namespace Xamarin.Forms } } + public string RuntimePlatform => Device.Android; + public void OpenUriAction(Uri uri) { global::Android.Net.Uri aUri = global::Android.Net.Uri.Parse(uri.ToString()); diff --git a/Xamarin.Forms.Platform.WP8/Forms.cs b/Xamarin.Forms.Platform.WP8/Forms.cs index f5546b80..d2a40d12 100644 --- a/Xamarin.Forms.Platform.WP8/Forms.cs +++ b/Xamarin.Forms.Platform.WP8/Forms.cs @@ -50,7 +50,6 @@ namespace Xamarin.Forms Log.Listeners.Add(new DelegateLogListener((c, m) => Console.WriteLine("[{0}] {1}", m, c))); - Device.OS = TargetPlatform.WinPhone; Device.PlatformServices = new WP8PlatformServices(); Device.Info = new WP8DeviceInfo(); diff --git a/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs b/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs index cd9f44f9..66126631 100644 --- a/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs +++ b/Xamarin.Forms.Platform.WP8/WP8PlatformServices.cs @@ -113,6 +113,8 @@ namespace Xamarin.Forms get { return !Deployment.Current.Dispatcher.CheckAccess(); } } + public string RuntimePlatform => Device.WinPhone; + public void OpenUriAction(Uri uri) { Launcher.LaunchUriAsync(uri).WatchForError(); diff --git a/Xamarin.Forms.Platform.WinRT.Phone/Forms.cs b/Xamarin.Forms.Platform.WinRT.Phone/Forms.cs index 62b4624c..bc91936a 100644 --- a/Xamarin.Forms.Platform.WinRT.Phone/Forms.cs +++ b/Xamarin.Forms.Platform.WinRT.Phone/Forms.cs @@ -25,7 +25,6 @@ namespace Xamarin.Forms Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add (GetPhoneResources()); - Device.OS = TargetPlatform.Windows; Device.PlatformServices = new WindowsPhonePlatformServices (Window.Current.Dispatcher); Device.Info = new WindowsDeviceInfo(); Device.Idiom = TargetIdiom.Phone; diff --git a/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs b/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs index 4dab045d..2f639099 100644 --- a/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs +++ b/Xamarin.Forms.Platform.WinRT.Tablet/Forms.cs @@ -40,7 +40,6 @@ namespace Xamarin.Forms Windows.UI.Xaml.Application.Current.Resources.MergedDictionaries.Add(GetTabletResources()); - Device.OS = TargetPlatform.Windows; Device.Idiom = TargetIdiom.Tablet; Device.PlatformServices = new WindowsPlatformServices(Window.Current.Dispatcher); Device.Info = new WindowsDeviceInfo(); diff --git a/Xamarin.Forms.Platform.WinRT/WindowsBasePlatformServices.cs b/Xamarin.Forms.Platform.WinRT/WindowsBasePlatformServices.cs index 310b66c3..3b5999f6 100644 --- a/Xamarin.Forms.Platform.WinRT/WindowsBasePlatformServices.cs +++ b/Xamarin.Forms.Platform.WinRT/WindowsBasePlatformServices.cs @@ -116,6 +116,8 @@ namespace Xamarin.Forms.Platform.WinRT public bool IsInvokeRequired => !CoreApplication.MainView.CoreWindow.Dispatcher.HasThreadAccess; + public string RuntimePlatform => Device.Windows; + public void OpenUriAction(Uri uri) { Launcher.LaunchUriAsync(uri).WatchForError(); diff --git a/Xamarin.Forms.Platform.iOS/Forms.cs b/Xamarin.Forms.Platform.iOS/Forms.cs index 9b03f56d..2c8fc6f7 100644 --- a/Xamarin.Forms.Platform.iOS/Forms.cs +++ b/Xamarin.Forms.Platform.iOS/Forms.cs @@ -53,7 +53,6 @@ namespace Xamarin.Forms Log.Listeners.Add(new DelegateLogListener((c, m) => Trace.WriteLine(m, c))); - Device.OS = TargetPlatform.iOS; Device.PlatformServices = new IOSPlatformServices(); Device.Info = new IOSDeviceInfo(); @@ -199,6 +198,8 @@ namespace Xamarin.Forms public bool IsInvokeRequired => !NSThread.IsMain; + public string RuntimePlatform => Device.iOS; + public void OpenUriAction(Uri uri) { UIApplication.SharedApplication.OpenUrl(new NSUrl(uri.AbsoluteUri)); diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs index 00747db4..7a4030eb 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1545.cs @@ -1,10 +1,23 @@ using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { [TestFixture] public class Issue1545 { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices { RuntimePlatform = Device.iOS }; + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + [Test] public void BindingCanNotBeReused() { diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs index c1253040..8b5bf30e 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs @@ -1,6 +1,7 @@ using System; using NUnit.Framework; using System.Collections.ObjectModel; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { @@ -58,6 +59,13 @@ namespace Xamarin.Forms.Xaml.UnitTests { SeverityColorConverter.count = 0; InvertBoolenConverter.count = 0; + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; } [Test] diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs index 2e7bfa91..bb7ee70b 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1554.cs @@ -1,11 +1,24 @@ using System; using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { [TestFixture] public class Issue1554 { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + [Test] public void CollectionItemsInDataTemplate () { diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs index cd942319..91c84f8e 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1594.cs @@ -1,11 +1,24 @@ using System; using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { [TestFixture] public class Issue1594 { + [SetUp] + public void Setup() + { + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; + } + [Test] public void OnPlatformForButtonHeight () { @@ -23,21 +36,17 @@ namespace Xamarin.Forms.Xaml.UnitTests </Button.HeightRequest> </Button>"; - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; var button = new Button ().LoadFromXaml (xaml); Assert.AreEqual (33, button.HeightRequest); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; button = new Button ().LoadFromXaml (xaml); Assert.AreEqual (44, button.HeightRequest); - Device.OS = TargetPlatform.WinPhone; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.WinPhone; button = new Button ().LoadFromXaml (xaml); Assert.AreEqual (44, button.HeightRequest); - - } - } -} - +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs index ebf3fe18..d4ae92db 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Pr3384.xaml.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using Xamarin.Forms; using NUnit.Framework; +using Xamarin.Forms.Core.UnitTests; namespace Xamarin.Forms.Xaml.UnitTests { @@ -22,9 +23,15 @@ namespace Xamarin.Forms.Xaml.UnitTests public class Tests { [SetUp] - public void SetUp () + public void Setup() { - Device.OS = TargetPlatform.iOS; + Device.PlatformServices = new MockPlatformServices { RuntimePlatform = Device.iOS }; + } + + [TearDown] + public void TearDown() + { + Device.PlatformServices = null; } [TestCase (false)] diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported007.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported007.xaml.cs index 3d488be2..a5f15816 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported007.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported007.xaml.cs @@ -23,7 +23,7 @@ namespace Xamarin.Forms.Xaml.UnitTests [SetUp] public void Setup() { - Device.PlatformServices = new MockPlatformServices(); + Device.PlatformServices = new MockPlatformServices { RuntimePlatform = Device.iOS }; } [TearDown] @@ -35,7 +35,6 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestCase(true), TestCase(false)] public void ConstraintsAreEvaluatedWithOnPlatform(bool useCompiledXaml) { - Device.OS = TargetPlatform.iOS; var page = new Unreported007(useCompiledXaml); Assert.That(RelativeLayout.GetXConstraint(page.label), Is.TypeOf<Constraint>()); Assert.AreEqual(3, RelativeLayout.GetXConstraint(page.label).Compute(null)); diff --git a/Xamarin.Forms.Xaml.UnitTests/NativeViewsAndBindings.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/NativeViewsAndBindings.xaml.cs index ce02d63b..39039f7a 100644 --- a/Xamarin.Forms.Xaml.UnitTests/NativeViewsAndBindings.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/NativeViewsAndBindings.xaml.cs @@ -246,22 +246,22 @@ namespace Xamarin.Forms.Xaml.UnitTests Device.PlatformServices = null; } - void SetUpPlatform(TargetPlatform platform) + void SetUpPlatform(string platform) { - Device.OS = platform; - if (platform == TargetPlatform.iOS) { + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = platform; + if (platform == Device.iOS) { DependencyService.Register<INativeValueConverterService, MockIosNativeValueConverterService>(); DependencyService.Register<INativeBindingService, MockIosNativeBindingService>(); - } else if (platform == TargetPlatform.Android) { + } else if (platform == Device.Android) { DependencyService.Register<INativeValueConverterService, MockAndroidNativeValueConverterService>(); DependencyService.Register<INativeBindingService, MockAndroidNativeBindingService>(); } } - [TestCase(false, TargetPlatform.iOS)] - [TestCase(false, TargetPlatform.Android)] + [TestCase(false, Device.iOS)] + [TestCase(false, Device.Android)] //[TestCase(true)] - public void NativeInContentView(bool useCompiledXaml, TargetPlatform platform) + public void NativeInContentView(bool useCompiledXaml, string platform) { SetUpPlatform(platform); var layout = new NativeViewsAndBindings(useCompiledXaml); @@ -272,11 +272,11 @@ namespace Xamarin.Forms.Xaml.UnitTests var view = layout.view0; Assert.NotNull(view.Content); MockNativeView nativeView = null; - if (platform == TargetPlatform.iOS) { + if (platform == Device.iOS) { Assert.That(view.Content, Is.TypeOf<MockUIViewWrapper>()); Assert.That(((MockUIViewWrapper)view.Content).NativeView, Is.TypeOf<MockUIView>()); nativeView = ((MockUIViewWrapper)view.Content).NativeView; - } else if (platform == TargetPlatform.Android) { + } else if (platform == Device.Android) { Assert.That(view.Content, Is.TypeOf<MockAndroidViewWrapper>()); Assert.That(((MockAndroidViewWrapper)view.Content).NativeView, Is.TypeOf<MockAndroidView>()); nativeView = ((MockAndroidViewWrapper)view.Content).NativeView; diff --git a/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml b/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml index 7f470a4a..de9a1e67 100644 --- a/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml +++ b/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml @@ -36,6 +36,12 @@ <OnPlatform.Android>Bar</OnPlatform.Android> </OnPlatform> </Label.Text> + <Label.HeightRequest> + <OnPlatform x:TypeArguments="x:Double"> + <On Platform="iOS">21</On> + <On Platform="Android, FooBar">42</On> + </OnPlatform> + </Label.HeightRequest> </Label> </StackLayout> </ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs index d53a51c2..edfb695f 100644 --- a/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/OnPlatform.xaml.cs @@ -39,11 +39,11 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestCase (true)] public void BoolToVisibility (bool useCompiledXaml) { - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; var layout = new OnPlatform (useCompiledXaml); Assert.AreEqual (true, layout.label0.IsVisible); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; layout = new OnPlatform (useCompiledXaml); Assert.AreEqual (false, layout.label0.IsVisible); } @@ -52,11 +52,11 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestCase(true)] public void DoubleToWidth(bool useCompiledXaml) { - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; var layout = new OnPlatform(useCompiledXaml); Assert.AreEqual(20, layout.label0.WidthRequest); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; layout = new OnPlatform(useCompiledXaml); Assert.AreEqual(30, layout.label0.WidthRequest); } @@ -65,11 +65,11 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestCase(true)] public void StringToText(bool useCompiledXaml) { - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; var layout = new OnPlatform(useCompiledXaml); Assert.AreEqual("Foo", layout.label0.Text); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; layout = new OnPlatform(useCompiledXaml); Assert.AreEqual("Bar", layout.label0.Text); } @@ -81,16 +81,18 @@ namespace Xamarin.Forms.Xaml.UnitTests var layout = new OnPlatform(useCompiledXaml); var onplat = layout.Resources ["fontAttributes"] as OnPlatform<FontAttributes>; Assert.NotNull(onplat); +#pragma warning disable 612 Assert.AreEqual(FontAttributes.Bold, onplat.iOS); - Assert.AreEqual(FontAttributes.Italic, onplat.Android); +#pragma warning restore 612 + } [TestCase(false)] [TestCase(true)] public void OnPlatformAsResourceAreApplied(bool useCompiledXaml) { - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; var layout = new OnPlatform(useCompiledXaml); var onidiom = layout.Resources ["fontSize"] as OnIdiom<double>; Assert.NotNull(onidiom); @@ -98,10 +100,29 @@ namespace Xamarin.Forms.Xaml.UnitTests Assert.AreEqual(20, onidiom.Phone); Assert.AreEqual(FontAttributes.Bold, layout.label0.FontAttributes); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; layout = new OnPlatform(useCompiledXaml); Assert.AreEqual(FontAttributes.Italic, layout.label0.FontAttributes); } + + [TestCase(false)] + [TestCase(true)] + public void OnPlatform2Syntax(bool useCompiledXaml) + { + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; + var layout = new OnPlatform(useCompiledXaml); + Assert.AreEqual(42, layout.label0.HeightRequest); + + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; + layout = new OnPlatform(useCompiledXaml); + Assert.AreEqual(21, layout.label0.HeightRequest); + + + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = "FooBar"; + layout = new OnPlatform(useCompiledXaml); + Assert.AreEqual(42, layout.label0.HeightRequest); + + } } } }
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/OnPlatformTests.cs b/Xamarin.Forms.Xaml.UnitTests/OnPlatformTests.cs index fc7283ad..04084dea 100644 --- a/Xamarin.Forms.Xaml.UnitTests/OnPlatformTests.cs +++ b/Xamarin.Forms.Xaml.UnitTests/OnPlatformTests.cs @@ -8,6 +8,20 @@ namespace Xamarin.Forms.Xaml.UnitTests [TestFixture] public class OnPlatformTests : BaseTestFixture { + [SetUp] + public override void Setup() + { + base.Setup(); + Device.PlatformServices = new MockPlatformServices(); + } + + [TearDown] + public override void TearDown() + { + Device.PlatformServices = null; + base.TearDown(); + } + [Test] public void ApplyToProperty () { @@ -50,15 +64,15 @@ namespace Xamarin.Forms.Xaml.UnitTests ContentPage layout; - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; layout = new ContentPage ().LoadFromXaml (xaml); Assert.AreEqual (new Thickness (0, 20, 0, 0), layout.Padding); - Device.OS = TargetPlatform.Android; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.Android; layout = new ContentPage ().LoadFromXaml (xaml); Assert.AreEqual (new Thickness (0, 0, 10, 0), layout.Padding); - Device.OS = TargetPlatform.WinPhone; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.WinPhone; layout = new ContentPage ().LoadFromXaml (xaml); Assert.AreEqual (new Thickness (0, 20, 0, 20), layout.Padding); } @@ -81,7 +95,7 @@ namespace Xamarin.Forms.Xaml.UnitTests Image image; - Device.OS = TargetPlatform.iOS; + ((MockPlatformServices)Device.PlatformServices).RuntimePlatform = Device.iOS; image = new Image ().LoadFromXaml (xaml); Assert.AreEqual ("icon_twitter.png", (image.Source as FileImageSource).File); } diff --git a/Xamarin.Forms.Xaml/ValueConverterProvider.cs b/Xamarin.Forms.Xaml/ValueConverterProvider.cs index 0f3871b5..57570803 100644 --- a/Xamarin.Forms.Xaml/ValueConverterProvider.cs +++ b/Xamarin.Forms.Xaml/ValueConverterProvider.cs @@ -15,4 +15,4 @@ namespace Xamarin.Forms.Xaml return value.ConvertTo(toType, minfoRetriever, serviceProvider); } } -}
\ No newline at end of file +} diff --git a/Xamarin.Forms.Xaml/XamlParser.cs b/Xamarin.Forms.Xaml/XamlParser.cs index 594d1c6b..e5c49804 100644 --- a/Xamarin.Forms.Xaml/XamlParser.cs +++ b/Xamarin.Forms.Xaml/XamlParser.cs @@ -263,9 +263,12 @@ namespace Xamarin.Forms.Xaml XmlnsHelper.ParseXmlns(kvp.Value, out typeName, out ns, out asm, out targetPlatform); if (targetPlatform == null) continue; - TargetPlatform os; - if (Enum.TryParse<TargetPlatform>(targetPlatform, out os) && os != Device.OS) + try { + if (targetPlatform != Device.RuntimePlatform) + prefixes.Add(prefix); + } catch (InvalidOperationException) { prefixes.Add(prefix); + } } return prefixes; } diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml index 5bec0518..16d13483 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/Device.xml @@ -21,6 +21,21 @@ </remarks> </Docs> <Members> + <Member MemberName="Android"> + <MemberSignature Language="C#" Value="public const string Android;" /> + <MemberSignature Language="ILAsm" Value=".field public static literal string Android" /> + <MemberType>Field</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.String</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> <Member MemberName="BeginInvokeOnMainThread"> <MemberSignature Language="C#" Value="public static void BeginInvokeOnMainThread (Action action);" /> <MemberSignature Language="ILAsm" Value=".method public static hidebysig void BeginInvokeOnMainThread(class System.Action action) cil managed" /> @@ -129,6 +144,21 @@ Device.BeginInvokeOnMainThread (() => { </remarks> </Docs> </Member> + <Member MemberName="iOS"> + <MemberSignature Language="C#" Value="public const string iOS;" /> + <MemberSignature Language="ILAsm" Value=".field public static literal string iOS" /> + <MemberType>Field</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.String</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> <Member MemberName="OnPlatform"> <MemberSignature Language="C#" Value="public static void OnPlatform (Action iOS = null, Action Android = null, Action WinPhone = null, Action Default = null);" /> <MemberSignature Language="ILAsm" Value=".method public static hidebysig void OnPlatform(class System.Action iOS, class System.Action Android, class System.Action WinPhone, class System.Action Default) cil managed" /> @@ -142,6 +172,11 @@ Device.BeginInvokeOnMainThread (() => { <AssemblyVersion>1.5.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete("Use switch(RuntimePlatform) instead.")</AttributeName> + </Attribute> + </Attributes> <ReturnValue> <ReturnType>System.Void</ReturnType> </ReturnValue> @@ -181,6 +216,11 @@ Device.OnPlatform (iOS: () => label.Font = Font.OfSize ("HelveticaNeue-UltraLigh <AssemblyVersion>1.5.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete("Use switch(RuntimePlatform) instead.")</AttributeName> + </Attribute> + </Attributes> <ReturnValue> <ReturnType>T</ReturnType> </ReturnValue> @@ -210,44 +250,6 @@ button.HeightRequest = Device.OnPlatform (20,30,30); </remarks> </Docs> </Member> - <Member MemberName="OnPlatform<T>"> - <MemberSignature Language="C#" Value="public static T OnPlatform<T> (T iOS, T Android, T WinPhone, T Tizen);" /> - <MemberSignature Language="ILAsm" Value=".method public static hidebysig !!T OnPlatform<T>(!!T iOS, !!T Android, !!T WinPhone, !!T Tizen) cil managed" /> - <MemberType>Method</MemberType> - <AssemblyInfo> - <AssemblyVersion>2.0.0.0</AssemblyVersion> - </AssemblyInfo> - <ReturnValue> - <ReturnType>T</ReturnType> - </ReturnValue> - <TypeParameters> - <TypeParameter Name="T" /> - </TypeParameters> - <Parameters> - <Parameter Name="iOS" Type="T" /> - <Parameter Name="Android" Type="T" /> - <Parameter Name="WinPhone" Type="T" /> - <Parameter Name="Tizen" Type="T" /> - </Parameters> - <Docs> - <typeparam name="T">The type of the value to be returned.</typeparam> - <param name="iOS">The value for iOS.</param> - <param name="Android">The value for Android.</param> - <param name="WinPhone">The value for WinPhone.</param> - <param name="WinPhone">The value for Tizen.</param> - <summary>Returns different values depending on the <see cref="T:Xamarin.Forms.TargetOS" /> Xamarin.Forms is working on.</summary> - <returns>The value for the current OS.</returns> - <remarks> - <para>This example shows how to use different heights for a Button on different OS. - </para> - <example> - <code lang="C#"><![CDATA[ -button.HeightRequest = Device.OnPlatform (20,30,30); - ]]></code> - </example> - </remarks> - </Docs> - </Member> <Member MemberName="OpenUri"> <MemberSignature Language="C#" Value="public static void OpenUri (Uri uri);" /> <MemberSignature Language="ILAsm" Value=".method public static hidebysig void OpenUri(class System.Uri uri) cil managed" /> @@ -286,6 +288,11 @@ button.HeightRequest = Device.OnPlatform (20,30,30); <AssemblyVersion>1.5.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete("Use RuntimePlatform instead.")</AttributeName> + </Attribute> + </Attributes> <ReturnValue> <ReturnType>Xamarin.Forms.TargetPlatform</ReturnType> </ReturnValue> @@ -296,6 +303,22 @@ button.HeightRequest = Device.OnPlatform (20,30,30); </remarks> </Docs> </Member> + <Member MemberName="RuntimePlatform"> + <MemberSignature Language="C#" Value="public static string RuntimePlatform { get; }" /> + <MemberSignature Language="ILAsm" Value=".property string RuntimePlatform" /> + <MemberType>Property</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.String</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <value>To be added.</value> + <remarks>To be added.</remarks> + </Docs> + </Member> <Member MemberName="StartTimer"> <MemberSignature Language="C#" Value="public static void StartTimer (TimeSpan interval, Func<bool> callback);" /> <MemberSignature Language="ILAsm" Value=".method public static hidebysig void StartTimer(valuetype System.TimeSpan interval, class System.Func`1<bool> callback) cil managed" /> @@ -323,5 +346,35 @@ button.HeightRequest = Device.OnPlatform (20,30,30); <remarks>While the callback returns <see langword="true" />, the timer will keep recurring.</remarks> </Docs> </Member> + <Member MemberName="Windows"> + <MemberSignature Language="C#" Value="public const string Windows;" /> + <MemberSignature Language="ILAsm" Value=".field public static literal string Windows" /> + <MemberType>Field</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.String</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="WinPhone"> + <MemberSignature Language="C#" Value="public const string WinPhone;" /> + <MemberSignature Language="ILAsm" Value=".field public static literal string WinPhone" /> + <MemberType>Field</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.String</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> </Members> </Type> diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/On.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/On.xml new file mode 100644 index 00000000..65daa858 --- /dev/null +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/On.xml @@ -0,0 +1,68 @@ +<Type Name="On" FullName="Xamarin.Forms.On"> + <TypeSignature Language="C#" Value="public class On" /> + <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit On extends System.Object" /> + <AssemblyInfo> + <AssemblyName>Xamarin.Forms.Core</AssemblyName> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <Base> + <BaseTypeName>System.Object</BaseTypeName> + </Base> + <Interfaces /> + <Attributes> + <Attribute> + <AttributeName>Xamarin.Forms.ContentProperty("Value")</AttributeName> + </Attribute> + </Attributes> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + <Members> + <Member MemberName=".ctor"> + <MemberSignature Language="C#" Value="public On ();" /> + <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" /> + <MemberType>Constructor</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <Parameters /> + <Docs> + <summary>To be added.</summary> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="Platform"> + <MemberSignature Language="C#" Value="public System.Collections.Generic.IList<string> Platform { get; set; }" /> + <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Generic.IList`1<string> Platform" /> + <MemberType>Property</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.Collections.Generic.IList<System.String></ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <value>To be added.</value> + <remarks>To be added.</remarks> + </Docs> + </Member> + <Member MemberName="Value"> + <MemberSignature Language="C#" Value="public object Value { get; set; }" /> + <MemberSignature Language="ILAsm" Value=".property instance object Value" /> + <MemberType>Property</MemberType> + <AssemblyInfo> + <AssemblyVersion>2.0.0.0</AssemblyVersion> + </AssemblyInfo> + <ReturnValue> + <ReturnType>System.Object</ReturnType> + </ReturnValue> + <Docs> + <summary>To be added.</summary> + <value>To be added.</value> + <remarks>To be added.</remarks> + </Docs> + </Member> + </Members> +</Type> diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml index 1204cff8..b7f8f47c 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/OnPlatform`1.xml @@ -18,6 +18,11 @@ <BaseTypeName>System.Object</BaseTypeName> </Base> <Interfaces /> + <Attributes> + <Attribute> + <AttributeName>Xamarin.Forms.ContentProperty("Platforms")</AttributeName> + </Attribute> + </Attributes> <Docs> <typeparam name="T">To be added.</typeparam> <summary>Provides the platform-specific implementation of T for the current <see cref="P:Xamarin.Forms.Device.OS" />.</summary> @@ -56,6 +61,11 @@ <AssemblyVersion>1.5.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete</AttributeName> + </Attribute> + </Attributes> <ReturnValue> <ReturnType>T</ReturnType> </ReturnValue> @@ -78,6 +88,11 @@ <AssemblyVersion>1.5.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete</AttributeName> + </Attribute> + </Attributes> <ReturnValue> <ReturnType>T</ReturnType> </ReturnValue> @@ -113,18 +128,18 @@ <remarks>To be added.</remarks> </Docs> </Member> - <Member MemberName="Tizen"> - <MemberSignature Language="C#" Value="public T Tizen { get; set; }" /> - <MemberSignature Language="ILAsm" Value=".property instance !T Tizen" /> + <Member MemberName="Platforms"> + <MemberSignature Language="C#" Value="public System.Collections.Generic.IList<Xamarin.Forms.On> Platforms { get; }" /> + <MemberSignature Language="ILAsm" Value=".property instance class System.Collections.Generic.IList`1<class Xamarin.Forms.On> Platforms" /> <MemberType>Property</MemberType> <AssemblyInfo> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> <ReturnValue> - <ReturnType>T</ReturnType> + <ReturnType>System.Collections.Generic.IList<Xamarin.Forms.On></ReturnType> </ReturnValue> <Docs> - <summary>The type as it is implemented on the Tizen platform.</summary> + <summary>To be added.</summary> <value>To be added.</value> <remarks>To be added.</remarks> </Docs> @@ -142,6 +157,11 @@ <AssemblyVersion>1.5.0.0</AssemblyVersion> <AssemblyVersion>2.0.0.0</AssemblyVersion> </AssemblyInfo> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete</AttributeName> + </Attribute> + </Attributes> <ReturnValue> <ReturnType>T</ReturnType> </ReturnValue> diff --git a/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml b/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml index 9dc44669..9a0266fc 100644 --- a/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml +++ b/docs/Xamarin.Forms.Core/Xamarin.Forms/TargetPlatform.xml @@ -14,6 +14,11 @@ <Base> <BaseTypeName>System.Enum</BaseTypeName> </Base> + <Attributes> + <Attribute> + <AttributeName>System.Obsolete</AttributeName> + </Attribute> + </Attributes> <Docs> <summary>Indicates the kind of OS Forms is currently working on.</summary> <remarks> @@ -80,20 +85,6 @@ <summary>(Unused) Indicates that Forms is running on an undefined platform.</summary> </Docs> </Member> - <Member MemberName="Tizen"> - <MemberSignature Language="C#" Value="Tizen" /> - <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Xamarin.Forms.TargetPlatform Tizen = int32(5)" /> - <MemberType>Field</MemberType> - <AssemblyInfo> - <AssemblyVersion>2.0.0.0</AssemblyVersion> - </AssemblyInfo> - <ReturnValue> - <ReturnType>Xamarin.Forms.TargetPlatform</ReturnType> - </ReturnValue> - <Docs> - <summary>Indicates that forms is running on the Tizen platform.</summary> - </Docs> - </Member> <Member MemberName="Windows"> <MemberSignature Language="C#" Value="Windows" /> <MemberSignature Language="ILAsm" Value=".field public static literal valuetype Xamarin.Forms.TargetPlatform Windows = int32(4)" /> diff --git a/docs/Xamarin.Forms.Core/index.xml b/docs/Xamarin.Forms.Core/index.xml index 901945fb..1b6cb745 100644 --- a/docs/Xamarin.Forms.Core/index.xml +++ b/docs/Xamarin.Forms.Core/index.xml @@ -338,6 +338,7 @@ <Type Name="NavigationEventArgs" Kind="Class" /> <Type Name="NavigationMenu" Kind="Class" /> <Type Name="NavigationPage" Kind="Class" /> + <Type Name="On" Kind="Class" /> <Type Name="OnIdiom`1" DisplayName="OnIdiom<T>" Kind="Class" /> <Type Name="OnPlatform`1" DisplayName="OnPlatform<T>" Kind="Class" /> <Type Name="OpenGLView" Kind="Class" /> |