Exemplo n.º 1
0
        public static ZipSIPackage Open(Stream stream, bool read = true)
        {
            var zipPackage = new ZipSIPackage
            {
                _stream     = stream,
                _zipArchive = new ZipArchive(stream, read ? ZipArchiveMode.Read : ZipArchiveMode.Update, false)
            };

            var entry = zipPackage._zipArchive.GetEntry("[Content_Types].xml");

            if (entry != null)
            {
                using (var readStream = entry.Open())
                {
                    using (var reader = XmlReader.Create(readStream))
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element && reader.Name == "Default")
                            {
                                var ext  = reader["Extension"];
                                var type = reader["ContentType"];

                                zipPackage._contentTypes[ext.ToLower()] = type;
                            }
                        }
                    }
                }
            }

            return(zipPackage);
        }
Exemplo n.º 2
0
 public override ISIPackage CreatePackage(System.IO.Stream stream)
 {
     return(ZipSIPackage.Create(stream));
 }
Exemplo n.º 3
0
 public override ISIPackage GetPackage(System.IO.Stream stream, bool read = true)
 {
     return(ZipSIPackage.Open(stream, read));
 }