private void buttonSerialize_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.Cancel) { return; } int archivateIndex = comboBoxForArhivate.SelectedIndex; ClearReceiver receiver; if (archivateIndex > 0) { receiver = new ClearReceiver(comboBox1.SelectedIndex, saveFileDialog1.FileName, ListOfDrinks, ArchivateExtensions[archivateIndex - 1], Serializers); } else { receiver = new ClearReceiver(comboBox1.SelectedIndex, saveFileDialog1.FileName, ListOfDrinks, null, Serializers); } user.SetCommand(new ClearReceiverCommand(receiver)); user.PressButton(); /* string filename = saveFileDialog1.FileName; * string extension = GetExtension(filename); * try * { * if (comboBox1.SelectedIndex == 1) * { * ISerializable temp = Serializers.dict[extension.ToString()]; * temp = new DeflateDecorator(temp, filename); * temp.Serialize(new MemoryStream(), ListOfDrinks); * return; * } * else * { * using (FileStream fs = new FileStream(filename, FileMode.Create, FileAccess.Write)) * { * Serializers.dict[extension.ToString()].Serialize(fs, ListOfDrinks); * } * } * if (archivateIndex > 0) * { * Serializers.dict[ArchivateExtensions[archivateIndex - 1]].Serialize(new MemoryStream(), filename); * //Plugins[archivateIndex - 1].Archivate(filename); * } * } * catch (Exception exept1) * { * MessageBox.Show(exept1.Message.ToString()); * }*/ }
public ClearReceiverCommand(ClearReceiver receiver) { _receiver = receiver; }