Esempio n. 1
0
        protected override void Read(IPropertySet pset)
        {
            base.Read(pset);
            ExternalConsole = pset.GetValue(nameof(ExternalConsole), false);

            // read from run config if CurrentProfile.* is empty, for backward compatibility
            if (!pset.HasProperty(nameof(EnvironmentVariables)) && EnvironmentVariables.Count == 0)
            {
                EnvironmentVariables.Add("ASPNETCORE_ENVIRONMENT", "Development");
            }
#pragma warning disable CS0618 //disables warnings threw by obsolete methods used in nameof()
            if (CurrentProfile.LaunchBrowser == null)
            {
                CurrentProfile.LaunchBrowser = pset.GetValue(nameof(LaunchBrowser), true);
            }
            if (string.IsNullOrEmpty(CurrentProfile.TryGetApplicationUrl()))
            {
                if (CurrentProfile.OtherSettings == null)
                {
                    CurrentProfile.OtherSettings = new Dictionary <string, object> (StringComparer.Ordinal);
                }

                CurrentProfile.OtherSettings ["applicationUrl"] = pset.GetValue(nameof(ApplicationURL), "http://localhost:5000/");
            }
            if (string.IsNullOrEmpty(CurrentProfile.LaunchUrl))
            {
                CurrentProfile.LaunchUrl = pset.GetValue(nameof(LaunchUrl), null);
            }
#pragma warning restore CS0618
        }
Esempio n. 2
0
        public string GetApplicationUrl()
        {
            var applicationUrl = CurrentProfile.TryGetApplicationUrl();

            if (applicationUrl != null)
            {
                return(applicationUrl);
            }

            return("http://localhost:5000");
        }
Esempio n. 3
0
        internal bool UsingHttps()
        {
            var applicationUrl = CurrentProfile.TryGetApplicationUrl();

            if (!string.IsNullOrEmpty(applicationUrl))
            {
                return(applicationUrl.IndexOf("https://", StringComparison.OrdinalIgnoreCase) >= 0);
            }

            var environmentVariables = (IDictionary <string, string>)EnvironmentVariables;

            if (environmentVariables.TryGetValue("ASPNETCORE_URLS", out string applicationUrls))
            {
                if (applicationUrls != null)
                {
                    return(applicationUrls.IndexOf("https://", StringComparison.OrdinalIgnoreCase) >= 0);
                }
            }

            return(false);
        }
Esempio n. 4
0
        protected override void Write(IPropertySet pset)
        {
            base.Write(pset);

            pset.SetValue(nameof(ExternalConsole), ExternalConsole, false);
            if (EnvironmentVariables.Count == 1 && EnvironmentVariables.ContainsKey("ASPNETCORE_ENVIRONMENT") && EnvironmentVariables ["ASPNETCORE_ENVIRONMENT"] == "Development")
            {
                pset.RemoveProperty(nameof(EnvironmentVariables));
            }

            if (CurrentProfile == null)
            {
                return;
            }

            CurrentProfile.EnvironmentVariables.Clear();
            foreach (var pair in EnvironmentVariables)
            {
                CurrentProfile.EnvironmentVariables [pair.Key] = pair.Value;
            }

            OnSaveRequested();

#pragma warning disable CS0618
            // persist values to Run Configuration for backward compatibility
            pset.SetValue(nameof(LaunchBrowser), CurrentProfile.LaunchBrowser, true);
            pset.SetValue(nameof(LaunchUrl), string.IsNullOrWhiteSpace(CurrentProfile.LaunchUrl) ? null : CurrentProfile.LaunchUrl, null);
            var appUrl = CurrentProfile.TryGetApplicationUrl();
            if (!string.IsNullOrEmpty(appUrl))
            {
                pset.SetValue(nameof(ApplicationURL), appUrl, "http://localhost:5000/");
            }
#pragma warning restore CS0618

            IsDirty = false;
        }