示例#1
0
        public void AddPackage(IPackage package, IEnumerable <string> files)
        {
            lock (thisLock)
            {
                var filepath      = Path.Combine(rootDirectory.FullName, GetPackagePath(package.Name, package.SemanticVersion()));
                var packageFolder = Path.Combine(rootDirectory.FullName, GetPackageRoot(package.Name, package.SemanticVersion()));

                if (Directory.Exists(packageFolder))
                {
                    Directory.Delete(packageFolder, true);
                }

                if (!Directory.Exists(packageFolder))
                {
                    Directory.CreateDirectory(packageFolder);
                }

                using (var stream = PackageBuilder.CreatePackage(package, files))
                {
                    using (var fileStream = File.Create(filepath))
                    {
                        stream.Seek(0, SeekOrigin.Begin);
                        stream.CopyTo(fileStream);
                    }
                }

                ManifestHelper.Save(package, Path.Combine(packageFolder, Constants.ManifestFileName));
            }
        }
示例#2
0
        public void TestMethodSaveFile()
        {
            var manifest = ManifestHelper.Load("Ressources\\Manifest.xml");

            ManifestHelper.Save(manifest, "Manifest.xml");
            Assert.IsTrue(File.Exists("Manifest.xml"));
        }
示例#3
0
        public void TestMethodSaveStream()
        {
            var manifest = ManifestHelper.Load("Ressources\\Manifest.xml");

            using (var stream = new FileStream("Manifest.xml", FileMode.Create, FileAccess.Write))
            {
                ManifestHelper.Save(manifest, stream);
            }
            Assert.IsTrue(File.Exists("Manifest.xml"));
        }