Example #1
0
        public async Task <(EntityIdentity oldProfileId, EntityIdentity newProfileId)?> RenameLaunchProfileAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, string currentProfileName, string newProfileName, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            ILaunchSettings launchSettings = await _launchSettingsProvider.WaitForFirstSnapshot(cancellationToken);

            ProjectSystem.Debug.ILaunchProfile?existingProfile = launchSettings.Profiles.FirstOrDefault(p => StringComparers.LaunchProfileNames.Equals(p.Name, currentProfileName));
            if (existingProfile is not null)
            {
                var writableProfile = new WritableLaunchProfile(existingProfile);
                writableProfile.Name = newProfileName;

                await _launchSettingsProvider.RemoveProfileAsync(currentProfileName);

                await _launchSettingsProvider.AddOrUpdateProfileAsync(writableProfile.ToLaunchProfile(), addToFront : false);

                if (_launchSettingsProvider.CurrentSnapshot is IVersionedLaunchSettings versionedLaunchSettings)
                {
                    queryExecutionContext.ReportUpdatedDataVersion(_launchSettingsTracker.VersionKey, versionedLaunchSettings.Version);
                }

                return(CreateLaunchProfileId(parent, currentProfileName), CreateLaunchProfileId(parent, newProfileName));
            }

            return(null);
        }
Example #2
0
        public async Task <EntityIdentity?> RemoveLaunchProfileAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, string profileName, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            await _launchSettingsProvider.RemoveProfileAsync(profileName);

            if (_launchSettingsProvider.CurrentSnapshot is IVersionedLaunchSettings versionedLaunchSettings)
            {
                queryExecutionContext.ReportUpdatedDataVersion(_launchSettingsTracker.VersionKey, versionedLaunchSettings.Version);
            }

            return(CreateLaunchProfileId(parent, profileName));
        }
Example #3
0
        public async Task <EntityIdentity?> AddLaunchProfileAsync(IQueryExecutionContext queryExecutionContext, IEntityValue parent, string commandName, string?newProfileName, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            newProfileName ??= await GetNewProfileNameAsync(cancellationToken);

            await _launchSettingsProvider.AddOrUpdateProfileAsync(
                new WritableLaunchProfile
            {
                Name        = newProfileName,
                CommandName = commandName
            }.ToLaunchProfile(),
                addToFront : false);

            if (_launchSettingsProvider.CurrentSnapshot is IVersionedLaunchSettings versionedLaunchSettings)
            {
                queryExecutionContext.ReportUpdatedDataVersion(_launchSettingsTracker.VersionKey, versionedLaunchSettings.Version);
            }

            return(CreateLaunchProfileId(parent, newProfileName));
        }
Example #4
0
 public static void ReportProjectUpdate(this IQueryExecutionContext queryExecutionContext, UnconfiguredProject unconfiguredProject)
 {
     unconfiguredProject.GetQueryDataVersion(out string versionKey, out long versionNumber);
     queryExecutionContext.ReportUpdatedDataVersion(versionKey, versionNumber);
 }