public void MakeSfx(Stream archive, Dictionary <string, string> settings, Stream sfxStream)
 {
     if (!sfxStream.CanWrite)
     {
         throw new ArgumentException("The specified output stream can not write.", nameof(sfxStream));
     }
     this.ValidateSettings(settings);
     using (Stream src = this._Module == SfxModule.Default ? Assembly.GetExecutingAssembly().GetManifestResourceStream(SevenZipSfx.GetResourceString(SevenZipSfx.SfxSupportedModuleNames[this._Module][0])) : (Stream) new FileStream(this._ModuleFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         SevenZipSfx.WriteStream(src, sfxStream);
     if (this._Module == SfxModule.Custom || this._SfxCommands[this._Module] != null)
     {
         using (Stream settingsStream = SevenZipSfx.GetSettingsStream(settings))
             SevenZipSfx.WriteStream(settingsStream, sfxStream);
     }
     SevenZipSfx.WriteStream(archive, sfxStream);
 }
 private void LoadCommandsFromResource(string xmlDefinitions)
 {
     using (Stream manifestResourceStream1 = Assembly.GetExecutingAssembly().GetManifestResourceStream(SevenZipSfx.GetResourceString(xmlDefinitions + ".xml")))
     {
         if (manifestResourceStream1 == null)
         {
             throw new SevenZipSfxValidationException("The configuration \"" + xmlDefinitions + "\" does not exist.");
         }
         using (Stream manifestResourceStream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream(SevenZipSfx.GetResourceString(xmlDefinitions + ".xsd")))
         {
             if (manifestResourceStream2 == null)
             {
                 throw new SevenZipSfxValidationException("The configuration schema \"" + xmlDefinitions + "\" does not exist.");
             }
             XmlSchemaSet xmlSchemaSet = new XmlSchemaSet();
             using (XmlReader schemaDocument = XmlReader.Create(manifestResourceStream2))
             {
                 xmlSchemaSet.Add((string)null, schemaDocument);
                 XmlReaderSettings settings = new XmlReaderSettings()
                 {
                     ValidationType = ValidationType.Schema, Schemas = xmlSchemaSet
                 };
                 string validationErrors = "";
                 // ISSUE: reference to a compiler-generated field
                 settings.ValidationEventHandler += (ValidationEventHandler)((s, t) => validationErrors += string.Format((IFormatProvider)CultureInfo.InvariantCulture, "[{0}]: {1}\n", new object[2]
                 {
                     (object)t.Severity.ToString(),
                     (object)t.Message
                 }));
                 using (XmlReader xmlReader = XmlReader.Create(manifestResourceStream1, settings))
                 {
                     this._SfxCommands = new Dictionary <SfxModule, List <string> >();
                     xmlReader.Read();
                     xmlReader.Read();
                     xmlReader.Read();
                     xmlReader.Read();
                     xmlReader.Read();
                     xmlReader.ReadStartElement("sfxConfigs");
                     xmlReader.Read();
                     do
                     {
                         SfxModule moduleByName = SevenZipSfx.GetModuleByName(xmlReader["modules"]);
                         xmlReader.ReadStartElement("config");
                         xmlReader.Read();
                         if (xmlReader.Name == "id")
                         {
                             List <string> stringList = new List <string>();
                             this._SfxCommands.Add(moduleByName, stringList);
                             do
                             {
                                 stringList.Add(xmlReader["command"]);
                                 xmlReader.Read();
                                 xmlReader.Read();
                             }while (xmlReader.Name == "id");
                             xmlReader.ReadEndElement();
                             xmlReader.Read();
                         }
                         else
                         {
                             this._SfxCommands.Add(moduleByName, (List <string>)null);
                         }
                     }while (xmlReader.Name == "config");
                 }
                 if (!string.IsNullOrEmpty(validationErrors))
                 {
                     throw new SevenZipSfxValidationException("\n" + validationErrors.Substring(0, validationErrors.Length - 1));
                 }
                 this._SfxCommands.Add(SfxModule.Default, this._SfxCommands[SfxModule.Extended]);
             }
         }
     }
 }