private static T GetOtherProperty <T>(ILaunchProfile launchProfile, string propertyName, T defaultValue)
        {
            if (launchProfile.TryGetSetting(propertyName, out object?value))
            {
                if (value is T b)
                {
                    return(b);
                }

                if (value is string s &&
                    TypeDescriptor.GetConverter(typeof(T)) is TypeConverter converter &&
                    converter.CanConvertFrom(typeof(string)))
                {
                    try
                    {
                        if (converter.ConvertFromString(s) is T o)
                        {
                            return(o);
                        }
                    }
                    catch (Exception)
                    {
                        // ignore bad data in the json file and just let them have the default value
                    }
                }
            }

            return(defaultValue);
        }
Esempio n. 2
0
        public static string?RemoteDebugMachine(this ILaunchProfile profile)
        {
            if (profile.TryGetSetting(RemoteDebugMachineProperty, out object?value) &&
                value is string s)
            {
                return(s);
            }

            return(null);
        }
Esempio n. 3
0
        public static bool IsRemoteDebugEnabled(this ILaunchProfile profile)
        {
            if (profile.TryGetSetting(RemoteDebugEnabledProperty, out object?value) &&
                value is bool b)
            {
                return(b);
            }

            return(false);
        }
Esempio n. 4
0
        /// <summary>
        /// Returns true if jsWebView2Debugging property is set to true
        /// </summary>
        public static bool IsJSWebView2DebuggingEnabled(this ILaunchProfile profile)
        {
            if (profile.TryGetSetting(JSWebView2DebuggingProperty, out object?value) &&
                value is bool b)
            {
                return(b);
            }

            return(false);
        }
Esempio n. 5
0
        public static bool IsHotReloadEnabled(this ILaunchProfile profile)
        {
            if (profile.TryGetSetting(HotReloadEnabledProperty, out object?value) &&
                value is bool b)
            {
                return(b);
            }

            return(true);
        }
Esempio n. 6
0
        public static string?RemoteAuthenticationMode(this ILaunchProfile profile)
        {
            if (profile.TryGetSetting(RemoteAuthenticationModeProperty, out object?value) &&
                value is string s)
            {
                return(s);
            }

            return(null);
        }