Example #1
0
        /// <summary>
        /// will be called when a nugetDependency switched its targetframework
        /// </summary>
        /// <param name="dependency"></param>
        private void OnDependencyRemovedFromGroup(NuGetDependency dependency)
        {
            RemoveDependency(dependency);

            if (OnDependencyRemoved != null)
            {
                OnDependencyRemoved(dependency, this);
            }
        }
        /// <summary>
        /// adds the given nuget dependency to the list and refresh the control
        /// </summary>
        /// <param name="dependency">dependency to add</param>
        public void AddDependency(NuGetDependency dependency)
        {
            Group.Dependencies.Add(dependency.Dependency);

            dependency.OnRemoveFromDependencyGroup = OnDependencyRemovedFromGroup;

            _uiDependencies.Items.Add(dependency);

            _uiItemsCount.Text = _uiDependencies.Items.Count.ToString();

            Refresh();
        }
Example #3
0
        /// <summary>
        /// adds the given nuget dependency to the list and refresh the control
        /// </summary>
        /// <param name="dependency">dependency to add</param>
        public void AddDependency(NuGetDependency dependency)
        {
            Group.Dependencies.Add(dependency.Dependency);

            dependency.OnRemoveFromDependencyGroup = OnDependencyRemovedFromGroup;

            _uiDependencies.Items.Add(dependency);

            _uiItemsCount.Text = _uiDependencies.Items.Count.ToString();

            Refresh();
        }
 /// <summary>
 /// removes the given dependency from the list if it exists
 /// </summary>
 /// <param name="dependency">dependency to remove</param>
 /// <returns>true if the dependency was removed</returns>
 public bool RemoveDependency(NuGetDependency dependency)
 {
     return RemoveDependencyById(dependency.Dependency.Id);
 }
        /// <summary>
        /// will be called when a nugetDependency switched its targetframework
        /// </summary>
        /// <param name="dependency"></param>
        private void OnDependencyRemovedFromGroup(NuGetDependency dependency)
        {
            RemoveDependency(dependency);

            if (OnDependencyRemoved != null)
                OnDependencyRemoved(dependency, this);
        }
Example #6
0
 /// <summary>
 /// removes the given dependency from the list if it exists
 /// </summary>
 /// <param name="dependency">dependency to remove</param>
 /// <returns>true if the dependency was removed</returns>
 public bool RemoveDependency(NuGetDependency dependency)
 {
     return(RemoveDependencyById(dependency.Dependency.Id));
 }
        /// <summary>
        /// will be called when a group of a dependency should be switched
        /// </summary>
        /// <param name="dependency">dependency that needs to be switched</param>
        /// <param name="originalGroup">the original group the dependency was placed in before</param>
        private void OnNuGetDependencyRemoved(NuGetDependency dependency, NuGetDependencyGroup originalGroup)
        {
            //here we check whether the dependency will be placed in its original group or the default group
            string targetFrameworkToLookFor = string.IsNullOrEmpty(originalGroup.Group.TargetFramework) ? dependency.Dependency.OriginalTargetFramework : null;

            //check if the original group has any dependencies left, if not it is not needed anymore
            if (originalGroup.Group.Dependencies.Count == 0)
            {
                _deployInfo.NuSpecPackage.Metadata.DependencyGroups.Remove(originalGroup.Group);

                _uiNuSpecDependencyGroups.Items.Remove(originalGroup);
            }

            //add the dependency to the new group
            foreach (NuGetDependencyGroup group in _uiNuSpecDependencyGroups.Items)
            {
                if (group.Group.TargetFramework == targetFrameworkToLookFor)
                {
                    group.AddDependency(dependency);
                    return;
                }
            }

            //if no group with the needed framework exists, it will be created and added
            Xml.NuGet.NuSpec.Group newGroup = new Xml.NuGet.NuSpec.Group() { TargetFramework = targetFrameworkToLookFor, Dependencies = new List<Xml.NuGet.NuSpec.Dependency>() };

            newGroup.Dependencies.Add(dependency.Dependency);

            _deployInfo.NuSpecPackage.Metadata.DependencyGroups.Add(newGroup);

            _uiNuSpecDependencyGroups.Items.Add(new NuGetDependencyGroup(newGroup) { OnDependencyRemoved = OnNuGetDependencyRemoved });
        }