Ejemplo n.º 1
0
        private static List <CSProjectDependency> GetFileList(XDocument xdoc, string elementName, string[] extensionList)
        {
            var returnValue = new List <CSProjectDependency>();
            var nodes       = xdoc.Descendants().Where(i => i.Name.LocalName == elementName && i.Attributes().Any(j => j.Name.LocalName == "Include" && extensionList.Contains(Path.GetExtension(j.Value), StringComparer.CurrentCultureIgnoreCase)));

            foreach (var node in nodes)
            {
                var item = new CSProjectDependency();
                item.FilePath = node.Attributes().Single(i => i.Name.LocalName == "Include").Value;
                var dependentUponNode = node.Elements().SingleOrDefault(i => i.Name.LocalName == "DependentUpon");
                if (dependentUponNode != null)
                {
                    string relativeDirectory = Path.GetDirectoryName(item.FilePath);
                    string dependentUponPath = dependentUponNode.Value;
                    if (!string.IsNullOrEmpty(relativeDirectory))
                    {
                        dependentUponPath = Path.Combine(relativeDirectory, dependentUponNode.Value);
                    }
                    item.DependentUponFilePath = dependentUponPath;
                }
                returnValue.Add(item);
            }
            return(returnValue);
        }
Ejemplo n.º 2
0
		private static List<CSProjectDependency> GetFileList(XDocument xdoc, string elementName, string[] extensionList)
		{
			var returnValue = new List<CSProjectDependency>();
			var nodes = xdoc.Descendants().Where(i => i.Name.LocalName == elementName && i.Attributes().Any(j => j.Name.LocalName == "Include" && extensionList.Contains(Path.GetExtension(j.Value), StringComparer.CurrentCultureIgnoreCase)));
			foreach (var node in nodes)
			{
				var item = new CSProjectDependency();
				item.FilePath = node.Attributes().Single(i => i.Name.LocalName == "Include").Value;
				var dependentUponNode = node.Elements().SingleOrDefault(i=>i.Name.LocalName == "DependentUpon");
				if(dependentUponNode != null)
				{
					string relativeDirectory = Path.GetDirectoryName(item.FilePath);
					string dependentUponPath = dependentUponNode.Value;
					if(!string.IsNullOrEmpty(relativeDirectory))
					{
						dependentUponPath = Path.Combine(relativeDirectory, dependentUponNode.Value);
					}
					item.DependentUponFilePath = dependentUponPath;
				}
				returnValue.Add(item);
			}
			return returnValue;
		}