Ejemplo n.º 1
0
 /// <summary>
 ///     Adds a .NET assembly to the plugin archive.
 /// </summary>
 /// <param name="entryName">The relative name of the resulting file in the archive</param>
 /// <param name="assemblyFileName"></param>
 private Assembly AddAssembly(string entryName, string assemblyFileName)
 {
     using (var content = File.OpenRead(assemblyFileName))
     {
         PeHeader header;
         PortableExecutable.TryReadHeader(content, out header, leaveOpen: true);
         content.Position = 0;
         return(AddAssembly(entryName, content, header));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Adds a new file to the plugin package.
        /// </summary>
        /// <param name="entryName"></param>
        /// <param name="content"></param>
        public void AddFile(string entryName, Stream content)
        {
            PeHeader header;

            PortableExecutable.TryReadHeader(content, out header, leaveOpen: true);
            content.Position = 0;
            if (header != null)
            {
                if (header.IsClrAssembly)
                {
                    AddAssembly(entryName, content, header);
                }
                else
                {
                    AddNativeImage(entryName, content, header);
                }
            }
            else
            {
                AddFileRaw(entryName, content);
            }
        }