Example #1
0
        protected static Dictionary <string, object> GetSettingsToSerialize(ILaunchSettings curSettings)
        {
            var profileData = new Dictionary <string, Dictionary <string, object> >(StringComparer.Ordinal);

            foreach (ILaunchProfile profile in curSettings.Profiles)
            {
                if (ProfileShouldBePersisted(profile))
                {
                    profileData.Add(profile.Name, LaunchProfileData.ToSerializableForm(profile));
                }
            }

            var dataToSave = new Dictionary <string, object>(StringComparer.Ordinal);

            foreach ((string key, object value) in curSettings.GlobalSettings)
            {
                if (!value.IsInMemoryObject())
                {
                    dataToSave.Add(key, value);
                }
            }

            if (profileData.Count > 0)
            {
                dataToSave.Add(ProfilesSectionName, profileData);
            }

            return(dataToSave);
        }
Example #2
0
        /// <summary>
        /// Gets the serialization object for the set of profiles and custom settings. It filters out built in profiles that get added to
        /// wire up the debugger infrastructure (NoAction profiles). Returns a dictionary of the elements to serialize.
        /// </summary>
        protected Dictionary <string, object> GetSettingsToSerialize(ILaunchSettings curSettings)
        {
            var profileData = new Dictionary <string, Dictionary <string, object> >(StringComparer.Ordinal);

            foreach (var profile in curSettings.Profiles)
            {
                if (ProfileShouldBePersisted(profile))
                {
                    profileData.Add(profile.Name, LaunchProfileData.ToSerializableForm(profile));
                }
            }

            Dictionary <string, object> dataToSave = new Dictionary <string, object>(StringComparer.Ordinal);

            foreach (var setting in curSettings.GlobalSettings)
            {
                dataToSave.Add(setting.Key, setting.Value);
            }

            if (profileData.Count > 0)
            {
                dataToSave.Add(ProfilesSectionName, profileData);
            }

            return(dataToSave);
        }
Example #3
0
        public void LaunchProfileData_ToSerializableFormTests()
        {
            var jsonObject = JObject.Parse(JsonString1);
            var profiles   = LaunchProfileData.DeserializeProfiles((JObject)jsonObject["profiles"]);

            var profile             = profiles["IIS Express"];
            var serializableProfile = LaunchProfileData.ToSerializableForm(new LaunchProfile(profile));

            AssertEx.CollectionLength(serializableProfile, 3);
            Assert.Equal("IISExpress", serializableProfile["commandName"]);
            Assert.Equal("http://localhost:1234:/test.html", serializableProfile["launchUrl"]);
            Assert.True((bool)serializableProfile["launchBrowser"]);

            profile             = profiles["HasCustomValues"];
            serializableProfile = LaunchProfileData.ToSerializableForm(new LaunchProfile(profile));
            Assert.Equal(6, serializableProfile.Count);
            Assert.Equal("c:\\test\\project", serializableProfile["workingDirectory"]);
            Assert.Equal("c:\\test\\project\\bin\\project.exe", serializableProfile["executablePath"]);
            Assert.Equal("--arg1 --arg2", serializableProfile["commandLineArgs"]);
            Assert.True((bool)serializableProfile["custom1"]);
            Assert.Equal(124, serializableProfile["custom2"]);
            Assert.Equal("mycustomVal", serializableProfile["custom3"]);

            // tests launchBrowser:false is not rewritten
            profile             = profiles["Docker"];
            serializableProfile = LaunchProfileData.ToSerializableForm(new LaunchProfile(profile));
            AssertEx.CollectionLength(serializableProfile, 3);
            Assert.Equal("Docker", serializableProfile["commandName"]);
            Assert.Equal("some option in docker", serializableProfile["dockerOption1"]);
            Assert.Equal("Another option in docker", serializableProfile["dockerOption2"]);

            profile             = profiles["web"];
            serializableProfile = LaunchProfileData.ToSerializableForm(new LaunchProfile(profile));
            AssertEx.CollectionLength(serializableProfile, 3);
            Assert.Equal("Project", serializableProfile["commandName"]);
            Assert.True((bool)serializableProfile["launchBrowser"]);
            Assert.Equal("Development", ((IDictionary)serializableProfile["environmentVariables"])["ASPNET_ENVIRONMENT"]);
            Assert.Equal("c:\\Users\\billhie\\Documents\\projects\\WebApplication8\\src\\WebApplication8", ((IDictionary)serializableProfile["environmentVariables"])["ASPNET_APPLICATIONBASE"]);
        }