Beispiel #1
0
        public void SetOperationOptions(IOperationOptions options)
        {
            var op = options as SaveOperationOptions;

            if (op == null)
            {
                throw new ArgumentException(nameof(options));
            }
            else
            {
                _options = op;
            }
        }
Beispiel #2
0
        public async Task <bool> ExecuteAsync(IProject project, IOperationOptions options)
        {
            if (!(project is PackageListProject activeProject))
            {
                Log.Error("Project type is unsupported for this operation");
                return(false);
            }

            if (!(options is DependenciesGatherOptions operationOptions))
            {
                Log.Error("Options type is unsupported for this operation");
                return(false);
            }


            var updatedPackageCollection = new List <PackageReference>(activeProject.PackageCollection.Cast <PackageReference>());

            foreach (var reference in activeProject.PackageCollection)
            {
                await ResolvePackageReferenceDependencyAsync((PackageReference)reference, updatedPackageCollection, operationOptions.UseStableDependencies);
            }

            //setup new references collection
            updatedPackageCollection = updatedPackageCollection.Where(reference => reference.To != null).Distinct().ToList();

            if (operationOptions.BuildDependenciesOnlyFromList)
            {
                var identityFilterList = activeProject.PackageCollection.Cast <PackageReference>().Select(reference => reference.From).ToHashSet();
                updatedPackageCollection = updatedPackageCollection.Where(
                    reference => identityFilterList.Contains(reference.From) &&
                    identityFilterList.Contains(reference.To))
                                           .ToList();
            }

            activeProject.DependencyCollection = updatedPackageCollection.Cast <IEntity>();
            activeProject.IsFinished           = true;

            return(true);
        }