public static IEnumerable <IProjectReference> GetProjectReferences(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement)
        {
            var projectReferences = projectReferencesItemGroupXElement.GetProjectReferenceXElements()
                                    .Select(xElement => new ProjectReferenceXElement(xElement));

            return(projectReferences);
        }
コード例 #2
0
        public static ProjectReferencesItemGroupXElement AddProjectReferencesItemGroupXElement(this ProjectXElement projectXElement)
        {
            var xItemGroupXElement = projectXElement.AddItemGroupXElement();

            var projectReferencesItemGroupXElement = ProjectReferencesItemGroupXElement.New(xItemGroupXElement);

            return(projectReferencesItemGroupXElement);
        }
コード例 #3
0
        public static bool HasProjectReferencesItemGroupElement(this ProjectXElement projectXElement, out ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement)
        {
            var hasItemGroupElement = projectXElement.HasItemGroupElementWithChildFirstOrDefault(ProjectFileXmlElementName.ProjectReference, out var itemGroupElement);

            projectReferencesItemGroupXElement = hasItemGroupElement ? ProjectReferencesItemGroupXElement.New(itemGroupElement) : default;

            return(hasItemGroupElement);
        }
        public static bool HasProjectReference(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement, string projectFilePath, out IProjectReference projectReference)
        {
            projectReference = projectReferencesItemGroupXElement.GetProjectReferenceXElementsWhereProjectFilePath(projectFilePath)
                               .Select(xElement => ProjectReferenceXElement.From(xElement))
                               .SingleOrDefault();

            var hasProjectReference = ProjectReferenceHelper.WasFound(projectReference);

            return(hasProjectReference);
        }
        public static IProjectReference AddProjectReference(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement, string projectFilePath)
        {
            var hasProjectReferenceAlready = projectReferencesItemGroupXElement.HasProjectReference(projectFilePath);

            if (hasProjectReferenceAlready)
            {
                throw new InvalidOperationException($"Project already has project reference:\n{projectFilePath}");
            }

            var projectReference = ProjectReferenceXElement.New(projectReferencesItemGroupXElement, projectFilePath);

            return(projectReference);
        }
        public static bool RemoveProjectReference(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement, IProjectReference projectReference)
        {
            var xProjectReference = projectReferencesItemGroupXElement.GetProjectReferenceXElementsWhereProjectFilePath(projectReference.ProjectFilePath)
                                    .SingleOrDefault();

            var wasFound = XElementHelper.WasFound(xProjectReference);

            if (wasFound)
            {
                xProjectReference.Remove();
            }

            return(wasFound);
        }
        public static bool HasProjectReference(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement, string projectFilePath)
        {
            var hasProjectReference = projectReferencesItemGroupXElement.HasProjectReference(projectFilePath, out _);

            return(hasProjectReference);
        }
        public static IEnumerable <XElement> GetProjectReferenceXElementsWhereProjectFilePath(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement, string projectFilePath)
        {
            var xProjectReferences = projectReferencesItemGroupXElement.GetProjectReferenceXElements()
                                     .Where(xElement => xElement.Attribute(ProjectFileXmlElementName.Include).Value == projectFilePath);

            return(xProjectReferences);
        }
        public static IEnumerable <XElement> GetProjectReferenceXElements(this ProjectReferencesItemGroupXElement projectReferencesItemGroupXElement)
        {
            var projectReferenceXElements = projectReferencesItemGroupXElement.Value.Elements(ProjectFileXmlElementName.ProjectReference);

            return(projectReferenceXElements);
        }
コード例 #10
0
        public static ProjectReferencesItemGroupXElement AsProjectReferencesItemGroup(this XElement xElement)
        {
            var projectReferenceItemGroup = new ProjectReferencesItemGroupXElement(xElement);

            return(projectReferenceItemGroup);
        }
コード例 #11
0
        public static ProjectReferenceXElement New(ProjectReferencesItemGroupXElement parent, string projectFilePath)
        {
            var projectReference = ProjectReferenceXElement.New(parent.Value, projectFilePath);

            return(projectReference);
        }
コード例 #12
0
        public static ProjectReferencesItemGroupXElement New(XElement xElement)
        {
            var projectReferencesItemGroupXElement = new ProjectReferencesItemGroupXElement(xElement);

            return(projectReferencesItemGroupXElement);
        }