From efa4a3e656d0668537f63b46a1f875671d692f4f Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 2 Dec 2016 14:12:25 +0100 Subject: [PATCH] [generator] Remove #ifdef for ApplicationClassName. (#1292) --- src/generator.cs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/generator.cs b/src/generator.cs index 55866dbccc..8f2f5c20b7 100644 --- a/src/generator.cs +++ b/src/generator.cs @@ -1582,15 +1582,21 @@ public partial class Generator : IMemberGatherer { public bool SkipSystemDrawing; public static PlatformName CurrentPlatform; -#if MONOMAC - const string ApplicationClassName = "NSApplication"; -#elif WATCH - const string ApplicationClassName = "UIApplication"; -#elif TVOS - const string ApplicationClassName = "UIApplication"; -#else - const string ApplicationClassName = "UIApplication"; -#endif + + public static string ApplicationClassName { + get { + switch (CurrentPlatform) { + case PlatformName.iOS: + case PlatformName.WatchOS: + case PlatformName.TvOS: + return "UIApplication"; + case PlatformName.MacOSX: + return "NSApplication"; + default: + throw new BindingException (1047, "Unsupported platform: {0}. Please file a bug report (http://bugzilla.xamarin.com) with a test case.", CurrentPlatform); + } + } + } // Static version of the above (!Compat) field, set on each Go invocation, needed because some static // helper methods need to access this. This is the exact opposite of Compat.