コード例 #1
0
        protected PackageFileBase(string path)
        {
            Path = path;

            FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out var effectivePath);
            TargetFramework = new FrameworkName(NuGetFramework.Parse(effectivePath).DotNetFrameworkName);
            EffectivePath   = effectivePath;
        }
コード例 #2
0
        public StreamPackageFile(Stream stream, string path)
        {
            _stream = stream;

            Path = path;

            TargetFramework = FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out var effectivePath);
            EffectivePath   = effectivePath;

            LastWriteTime = DateTimeOffset.Now;
        }
コード例 #3
0
        private static IPackageFile CreatePackageFile(string name)
        {
            var file = new InMemoryFile();

            file.Path   = name;
            file.Stream = new MemoryStream();

            string effectivePath;
            var    fx = FrameworkNameUtility.ParseFrameworkNameFromFilePath(name, out effectivePath);

            file.EffectivePath   = effectivePath;
            file.TargetFramework = fx;

            return(file);
        }
コード例 #4
0
        protected PackageFileBase(string path)
        {
            Path = path;

            FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out var effectivePath);
            EffectivePath = effectivePath;

            try
            {
                TargetFramework = new FrameworkName(NuGetFramework.Parse(effectivePath).DotNetFrameworkName);
            }
            catch (ArgumentException) // could be an invalid framework/version
            {
            }
        }
コード例 #5
0
ファイル: PackageCreator.cs プロジェクト: yjpark/liget
        private static IPackageFile CreatePackageFile(string name)
        {
            var file = new Mock <IPackageFile>();

            file.SetupGet(f => f.Path).Returns(name);
            file.Setup(f => f.GetStream()).Returns(new MemoryStream());

            string effectivePath;
            var    fx = FrameworkNameUtility.ParseFrameworkNameFromFilePath(name, out effectivePath);

            file.SetupGet(f => f.EffectivePath).Returns(effectivePath);
            file.SetupGet(f => f.TargetFramework).Returns(fx);

            return(file.Object);
        }
コード例 #6
0
        private static bool IsValidFrameworkName(string path)
        {
            FrameworkName fx;

            try
            {
                string effectivePath;
                fx = FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out effectivePath);
            }
            catch (ArgumentException)
            {
                fx = null;
            }

            return(fx != null);
        }
コード例 #7
0
        private static bool IsValidFrameworkName(string path)
        {
            FrameworkName fx;

            try
            {
                string effectivePath;
                fx = FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out effectivePath);
            }
            catch (ArgumentException)
            {
                fx = null;
            }

            // return false if the framework is Null or Unsupported
            return(fx != null && fx.Identifier != NuGetFramework.UnsupportedFramework.Framework);
        }
コード例 #8
0
        public static Mock <IPackageFile> CreateMockedPackageFile(string directory, string fileName, string content = null)
        {
            string path = Path.Combine(directory, fileName);

            content = content ?? path;

            var mockFile = new Mock <IPackageFile>();

            mockFile.Setup(m => m.Path).Returns(path);
            mockFile.Setup(m => m.GetStream()).Returns(() => new MemoryStream(Encoding.Default.GetBytes(content)));

            string        effectivePath;
            FrameworkName fn = FrameworkNameUtility.ParseFrameworkNameFromFilePath(path, out effectivePath);

            mockFile.Setup(m => m.TargetFramework).Returns(fn);
            mockFile.Setup(m => m.EffectivePath).Returns(effectivePath);
            mockFile.Setup(m => m.TargetFramework).Returns(fn);
            return(mockFile);
        }