예제 #1
0
        public void SetContent()
        {
            MemoryStream ms = new MemoryStream();
            FileContentArchive.ZipStream zip = new FileContentArchive.ZipStream(ms);
            zip.UpdateContent("testentry/subentry", "some content");

            string content = zip.GetContent("testentry/subentry");

            Assert.AreEqual(content, "some content");
        }
예제 #2
0
        public void OverwriteContent()
        {
            MemoryStream ms = new MemoryStream();

            FileContentArchive.ZipStream zip = new FileContentArchive.ZipStream(ms);
            zip.UpdateContent("testentry/subentry", "some content");
            zip.UpdateContent("testentry/subentry", "another content");
            string content = zip.GetContent("testentry/subentry");

            Assert.AreEqual(content, "another content");
        }
예제 #3
0
        public static BuildArtifacts FromZipArchive(string AssemblyArtefactName, string versionTag, byte[] data)
        {
            string AssemblyArtefactNameSym  = (pathWithoutExtension(AssemblyArtefactName) + ".pdb").ToLower();
            string AssemblyArtefactNameSymL = (pathWithoutExtension(AssemblyArtefactName) + ".mdb").ToLower();

            BuildArtifacts result = new BuildArtifacts();

            FileContentArchive.ZipStream          zipArch = new FileContentArchive.ZipStream(data);
            FileContentArchive.FileStorageEntry[] entrys  = zipArch.GetAllEntrys();

            bool   artefactAssemblyFound    = false;
            string artefactAssemblySymFound = null;

            for (int i = 0; i < entrys.Length; i++)
            {
                if (entrys[i].IsDir)
                {
                    continue;
                }

                if (entrys[i].Location == AssemblyArtefactName)
                {
                    artefactAssemblyFound = true;
                }

                if (entrys[i].Location.ToLower() == AssemblyArtefactNameSym)
                {
                    artefactAssemblySymFound = AssemblyArtefactNameSym;
                }
                if (entrys[i].Location.ToLower() == AssemblyArtefactNameSymL)
                {
                    artefactAssemblySymFound = AssemblyArtefactNameSymL;
                }

                result.AddArtefact(entrys[i].Location, zipArch.GetContentRaw(entrys[i].Location));
            }

            zipArch.Close();

            result.AssemblyArtefactName    = AssemblyArtefactName;
            result.AssemblyArtefactNameSym = artefactAssemblySymFound;

            result.AddedAt    = DateTime.UtcNow;
            result.VersionTag = versionTag;

            if (!artefactAssemblyFound)
            {
                logger.Error(" BuildArtifacts:FromZipArchive assembly not found in zip : {0}", AssemblyArtefactName);
                return(null);
            }

            return(result);
        }
예제 #4
0
        public static BuildArtifacts FromZipArchive(string AssemblyArtefactName, string versionTag, byte[] data)
        {
            string AssemblyArtefactNameSym = (pathWithoutExtension(AssemblyArtefactName) + ".pdb").ToLower();
            string AssemblyArtefactNameSymL = (pathWithoutExtension(AssemblyArtefactName) + ".mdb").ToLower();

            BuildArtifacts result = new BuildArtifacts();
            FileContentArchive.ZipStream zipArch = new FileContentArchive.ZipStream(data);
            FileContentArchive.FileStorageEntry[] entrys = zipArch.GetAllEntrys();

            bool artefactAssemblyFound = false;
            string artefactAssemblySymFound = null;
            for (int i = 0; i < entrys.Length; i++)
            {
                if (entrys[i].IsDir)
                    continue;

                if (entrys[i].Location == AssemblyArtefactName)
                    artefactAssemblyFound = true;

                if (entrys[i].Location.ToLower() == AssemblyArtefactNameSym)
                    artefactAssemblySymFound = AssemblyArtefactNameSym;
                if (entrys[i].Location.ToLower() == AssemblyArtefactNameSymL)
                    artefactAssemblySymFound = AssemblyArtefactNameSymL;

                result.AddArtefact(entrys[i].Location, zipArch.GetContentRaw(entrys[i].Location));
            }

            zipArch.Close();

            result.AssemblyArtefactName = AssemblyArtefactName;
            result.AssemblyArtefactNameSym = artefactAssemblySymFound;

            result.AddedAt = DateTime.UtcNow;
            result.VersionTag = versionTag;

            if (!artefactAssemblyFound)
            {
                logger.Error(" BuildArtifacts:FromZipArchive assembly not found in zip : {0}", AssemblyArtefactName);
                return null;
            }

            return result;
        }