public AddEntry ( string entryName, OpenDelegate opener, CloseDelegate closer ) : |
||
entryName | string | the name of the entry to add |
opener | OpenDelegate | /// the delegate that will be invoked by ZipFile.Save() to get the /// readable stream for the given entry. ZipFile.Save() will call /// read on this stream to obtain the data for the entry. This data /// will then be compressed and written to the newly created zip /// file. /// |
closer | CloseDelegate | /// the delegate that will be invoked to close the stream. This may /// be null (Nothing in VB), in which case no call is makde to close /// the stream. /// |
return |
public ZipEntry AddEntry(string entryName, OpenDelegate opener, CloseDelegate closer)
{
ZipEntry ze = ZipEntry.CreateForJitStreamProvider(entryName, opener, closer);
ze.SetEntryTimes(DateTime.Now,DateTime.Now,DateTime.Now);
if (Verbose) StatusMessageTextWriter.WriteLine("adding {0}...", entryName);
return _InternalAddEntry(ze);
}
ZipFile::AddEntry ( string entryName, Stream stream ) : |
|
ZipFile::AddEntry ( string entryName, WriteDelegate writer ) : |
|
ZipFile::AddEntry ( string entryName, byte byteContent ) : |
|
ZipFile::AddEntry ( string entryName, string content ) : |
|
ZipFile::AddEntry ( string entryName, string content, System encoding ) : |
public static string CompileNewXAP(HashSet<string> fullsetOfDlls, string shared) { var tempPath = Path.Combine(shared, Guid.NewGuid() + ".xap"); using ( var stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream("sl_runner.xap.sl-50-xap.xap")) using (var baseZip = ZipFile.Read(stream)) { var set = new HashSet<string>(); var item = baseZip["AppManifest.xaml"]; var xml = XDocument.Parse(new StreamReader(item.OpenReader()).ReadToEnd()); using ( var zip = new ZipFile() { CompressionLevel = CompressionLevel.Default, CompressionMethod = CompressionMethod.Deflate }) { zip.AddEntry("AppManifest.xaml", new byte[] { }); foreach (var entry in baseZip.Entries) { if (entry.FileName.Contains(".dll")) { using (var memstream = new MemoryStream()) { entry.OpenReader().CopyTo(memstream); memstream.Seek(0, SeekOrigin.Begin); zip.AddEntry(entry.FileName, memstream.ToArray()); set.Add(Path.GetFileName(entry.FileName)); } } } var desc = xml.DescendantNodes().OfType<XElement>(); var parts = desc.Single(it => it.Name.LocalName.Contains("Deployment.Parts")); foreach (var dll in fullsetOfDlls) { if (set.Contains(Path.GetFileName(dll))) continue; set.Add(Path.GetFileName(dll)); zip.AddFile(dll, ""); parts.Add(new XElement(XName.Get("AssemblyPart", "http://schemas.microsoft.com/client/2007/deployment"), new XAttribute( XName.Get("Name", "http://schemas.microsoft.com/winfx/2006/xaml"), Path.GetFileNameWithoutExtension(dll)), new XAttribute("Source", Path.GetFileName(dll)))); } using (var memstream = new MemoryStream()) { xml.Save(memstream, SaveOptions.OmitDuplicateNamespaces); zip.UpdateEntry("AppManifest.xaml", memstream.ToArray()); } zip.Save(tempPath); } } return tempPath; }