Beispiel #1
0
        /// <summary>
        ///     Called when [startup profile changed].
        /// </summary>
        /// <param name="profile">The profile.</param>
        public void OnStartupProfileChanged(Profile profile)
        {
            if (profile == null)
            {
                return;
            }

            var startupProjects = profile.Projects.Select(s => _projectCache.TryGetProjectByName(s.Name, out var project) ? project : null).ToList();

            foreach (var startupProject in startupProjects.Where(s => s != null))
            {
                var startupProjectConfig = profile.Projects.FirstOrDefault(s => string.Equals(s.Name, startupProject.Name, StringComparison.OrdinalIgnoreCase));
                if (startupProjectConfig == null)
                {
                    continue;
                }

                foreach (EnvDTE.Configuration configuration in startupProject.Source.ConfigurationManager)
                {
                    if (configuration?.Properties == null)
                    {
                        continue;
                    }

                    foreach (var property in configuration.Properties.Cast <Property>())
                    {
                        if (property == null)
                        {
                            continue;
                        }

                        switch (property.Name)
                        {
                        case "StartArguments":
                            property.Value = startupProjectConfig.CommandLineArgs;
                            break;

                        case "StartWorkingDirectory":
                            property.Value = startupProjectConfig.WorkingDirectory;
                            break;

                        case "StartProgram":
                            property.Value = startupProjectConfig.StartExternalProgram;
                            break;

                        case "StartURL":
                            property.Value = startupProjectConfig.StartBrowserUrl;
                            break;

                        case "RemoteDebugEnabled":
                            property.Value = startupProjectConfig.IsRemoteDebuggingEnabled;
                            break;

                        case "RemoteDebugMachine":
                            property.Value = startupProjectConfig.RemoteDebuggingMachine;
                            break;

                        case "StartAction":
                            property.Value = (int)startupProjectConfig.GetStartAction();
                            break;
                        }
                    }
                }
            }

            Target.OnStartupProfileChanged(profile, startupProjects.Select(s => s.RelativePath).ToArray());
        }