Пример #1
0
        /// <summary>
        /// Returns a map of project property names / list of search paths for the specified toolsVersion and os
        /// </summary>
        protected override Dictionary <string, ProjectImportPathMatch> GetProjectImportSearchPathsTable(string toolsVersion, string os)
        {
            Dictionary <string, ProjectImportPathMatch> kindToPathsCache;
            var key = toolsVersion + ":" + os;

            if (_projectImportSearchPathsCache.TryGetValue(key, out kindToPathsCache))
            {
                return(kindToPathsCache);
            }

            // Read and populate the map
            kindToPathsCache = new Dictionary <string, ProjectImportPathMatch>();
            _projectImportSearchPathsCache[key] = kindToPathsCache;

            ToolsetElement toolsetElement     = ConfigurationSection.Toolsets.GetElement(toolsVersion);
            var            propertyCollection = toolsetElement?.AllProjectImportSearchPaths?.GetElement(os)?.PropertyElements;

            if (propertyCollection == null || propertyCollection.Count == 0)
            {
                return(kindToPathsCache);
            }

            kindToPathsCache = ComputeDistinctListOfSearchPaths(propertyCollection);

            return(kindToPathsCache);
        }
        /// <summary>
        /// Provides an enumerator over property definitions for a specified tools version
        /// </summary>
        protected override IEnumerable <ToolsetPropertyDefinition> GetPropertyDefinitions(string toolsVersion)
        {
            ToolsetElement toolsetElement = ConfigurationSection.Toolsets.GetElement(toolsVersion);

            if (toolsetElement == null)
            {
                yield break;
            }

            foreach (ToolsetElement.PropertyElement propertyElement in toolsetElement.PropertyElements)
            {
                ElementLocation location = ElementLocation.Create(propertyElement.ElementInformation.Source, propertyElement.ElementInformation.LineNumber, 0);

                if (propertyElement.Name != null && propertyElement.Name.Length == 0)
                {
                    InvalidToolsetDefinitionException.Throw("InvalidToolsetValueInConfigFileValue", location.LocationString);
                }

                yield return(new ToolsetPropertyDefinition(propertyElement.Name, propertyElement.Value, location));
            }
        }
Пример #3
0
        /// <summary>
        /// Returns a list of the search paths for a given search path property collection
        /// </summary>
        private Dictionary<string, List<string>> ComputeDistinctListOfSearchPaths(ToolsetElement.PropertyElementCollection propertyCollection)
        {
            var pathsTable = new Dictionary<string, List<string>>();

            foreach (ToolsetElement.PropertyElement property in propertyCollection)
            {
                if (string.IsNullOrEmpty(property.Value) || string.IsNullOrEmpty(property.Name))
                {
                    continue;
                }

                //FIXME: handle ; in path on Unix
                var paths =
                    property.Value.Split(new[] {_separatorForExtensionsPathSearchPaths},
                        StringSplitOptions.RemoveEmptyEntries).Distinct();

                pathsTable.Add(property.Name, paths.ToList());
            }

            return pathsTable;
        }