Exemple #1
0
        public async Task <bool> TryUpdateReferenceAsync(string projectPath, string targetFrameworkMoniker, ReferenceUpdate referenceUpdate, CancellationToken cancellationToken)
        {
            bool wasUpdated = false;

            if (referenceUpdate.Action == UpdateAction.None)
            {
                return(wasUpdated);
            }

            ConfiguredProject activeConfiguredProject = await GetActiveConfiguredProjectByPathAsync(projectPath);

            ReferenceHandler referenceHandler = FindReferenceHandler(referenceUpdate);

            if (referenceUpdate.Action == UpdateAction.TreatAsUsed || referenceUpdate.Action == UpdateAction.TreatAsUnused)
            {
                wasUpdated = await referenceHandler.UpdateReferenceAsync(activeConfiguredProject, referenceUpdate, cancellationToken);
            }
            else
            {
                wasUpdated = await referenceHandler.RemoveReferenceAsync(activeConfiguredProject, referenceUpdate.ReferenceInfo);
            }

            return(wasUpdated);
        }