ParseFrameworkFolderName() public static method

public static ParseFrameworkFolderName ( string path ) : FrameworkName
path string
return FrameworkName
        public ZipPackageAssemblyReference(IPackageFile file)
            : base(file)
        {
            Debug.Assert(Path.StartsWith("lib", StringComparison.OrdinalIgnoreCase), "path doesn't start with lib");

            // Get rid of the lib folder
            string path = Path.Substring(3).Trim(System.IO.Path.DirectorySeparatorChar);

            _targetFramework = VersionUtility.ParseFrameworkFolderName(path);
        }
示例#2
0
        public static FrameworkName ParseFrameworkNameFromFilePath(string filePath, out string effectivePath)
        {
            var knownFolders = new string[]
            {
                Constants.ContentDirectory,
                Constants.LibDirectory,
                Constants.ToolsDirectory,
                Constants.BuildDirectory
            };

            for (int i = 0; i < knownFolders.Length; i++)
            {
                string folderPrefix = knownFolders[i] + System.IO.Path.DirectorySeparatorChar;
                if (filePath.Length > folderPrefix.Length &&
                    filePath.StartsWith(folderPrefix, StringComparison.OrdinalIgnoreCase))
                {
                    string frameworkPart = filePath.Substring(folderPrefix.Length);

                    try
                    {
                        return(VersionUtility.ParseFrameworkFolderName(
                                   frameworkPart,
                                   strictParsing: knownFolders[i] == Constants.LibDirectory,
                                   effectivePath: out effectivePath));
                    }
                    catch (ArgumentException)
                    {
                        // if the parsing fails, we treat it as if this file
                        // doesn't have target framework.
                        effectivePath = frameworkPart;
                        return(null);
                    }
                }
            }

            effectivePath = filePath;
            return(null);
        }