Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Ksiazka : Publikacje
- {
- public string nazwawydawnictwa { set; get; }
- public Ksiazka()
- {
- }
- public Ksiazka(string autor, string tytul, int rokwydania, string nazwawydawnictwa, string metki)
- {
- this.autor = autor;
- this.tytul = tytul;
- this.rokwydania = rokwydania;
- this.nazwawydawnictwa = nazwawydawnictwa;
- this.metki = metki;
- }
- public void wyswietlanie()
- {
- serializacja master = new serializacja();
- master.Parts.Add(new Ksiazka());
- List<Type> partTypes = new List<Type>();
- foreach (Type type in typeof(Publikacje).Assembly.GetTypes())
- {
- if (type.IsSubclassOf(typeof(Publikacje)))
- partTypes.Add(type);
- }
- FileStream fileStream = new FileStream("data.xml", FileMode.Open);
- XmlSerializer xs = new XmlSerializer(master.GetType(), partTypes.ToArray());
- master = xs.Deserialize(fileStream) as List<serializacja>;
- fileStream.Close();
- Console.ReadLine();
- }
- public override void pobierzdane()
- {
- Console.WriteLine("Podaj imiona i nazwiska autora(ów): ");
- this.autor = Console.ReadLine();
- Console.WriteLine("Podaj tytuł książki: ");
- this.tytul = Console.ReadLine();
- Console.WriteLine("Podaj rok wydania: ");
- do
- {
- try
- {
- this.rokwydania = Convert.ToInt32(Console.ReadLine());
- }
- catch (Exception)
- {
- Console.WriteLine("Rok musi być liczbą, podaj rok wydania jeszcze raz");
- }
- } while (rokwydania == 0);
- Console.WriteLine("Podaj nazwę wydawnictwa: ");
- this.nazwawydawnictwa = Console.ReadLine();
- Console.WriteLine("Podaj słowa kluczowe(metki): ");
- this.metki = Console.ReadLine();
- Ksiazka dane = new Ksiazka(this.autor,this.tytul,this.rokwydania,this.nazwawydawnictwa,this.metki);
- {
- serializacja master = new serializacja();
- master.Parts.Add(dane);
- List<Type> partTypes = new List<Type>();
- foreach (Type type in typeof(Publikacje).Assembly.GetTypes())
- {
- if (type.IsSubclassOf(typeof(Publikacje)))
- partTypes.Add(type);
- }
- FileStream fileStream = new FileStream("data.xml", FileMode.Append);
- XmlSerializer xs = new XmlSerializer(master.GetType(), partTypes.ToArray());
- xs.Serialize(fileStream, master);
- fileStream.Close();
- Console.ReadLine();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment