/// <summary>
 /// Erstellt die Meldedatei anhand von <paramref name="data"/> neu.
 /// </summary>
 /// <param name="data">Die Daten die zur Erstellung der Meldedatei benutzt werden sollen</param>
 /// <param name="streamName">Der Name des Streams der für die Erstellung der Meldedatei benutzt werden soll</param>
 /// <returns>Die Meldedatei</returns>
 private string GetStringFromMessage(DeuevMessageData data, string streamName)
 {
     var output = new StringWriter();
     using (var writer = StreamFactory.CreateWriter(streamName, output))
     {
         foreach (var record in data.VOSZ)
             writer.Write(record);
         foreach (var record in data.DSKK)
             writer.Write(record);
         foreach (var record in data.NCSZ)
             writer.Write(record);
     }
     return output.ToString();
 }
        private DeuevMessageData GetMessageFromString(string input, string streamName)
        {
            var reader       = StreamFactory.CreateReader(streamName, new StringReader(input));
            var deuevMessage = new DeuevMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    streamObject = reader.Read();
                } while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                while (reader.RecordName == "DSKK" || reader.RecordName == "DSKK-v01")
                {
                    var record = Assert.IsType <DSKK01>(streamObject);
                    deuevMessage.DSKK.Add(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                } while (reader.RecordName != null && (reader.RecordName == "NCSZ-v01" || reader.RecordName == "NCSZ"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                return(deuevMessage);
            }
            catch (InvalidRecordException ex) when(LogInvalidRecordException(ex))
            {
                Debug.Assert(false, "Darf hier niemals landen");
                throw;
            }
            finally
            {
                reader.Close();
            }
        }
        private DeuevMessageData GetMessageFromString(string input, string streamName)
        {
            var reader       = StreamFactory.CreateReader(streamName, new StringReader(input));
            var deuevMessage = new DeuevMessageData();

            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType <VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    streamObject = reader.Read();
                } while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                var dsko = Assert.IsType <DSKO04>(streamObject);
                deuevMessage.DSKO = dsko;
                streamObject      = reader.Read();

                while (reader.RecordName == "DSME" || reader.RecordName == "DSME-v0301")
                {
                    var record = Assert.IsType <DSME0301>(streamObject);
                    deuevMessage.DSME.Add(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType <NCSZ>(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                } while (reader.RecordName != null && (reader.RecordName == "NCSZ-v01" || reader.RecordName == "NCSZ"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                return(deuevMessage);
            }
            finally
            {
                reader.Close();
            }
        }
        private DeuevMessageData GetMessageFromString(string input, string streamName)
        {
            var reader = StreamFactory.CreateReader(streamName, new StringReader(input));
            var deuevMessage = new DeuevMessageData();
            try
            {
                var streamObject = reader.Read();

                do
                {
                    var vosz = Assert.IsType<VOSZ>(streamObject);
                    deuevMessage.VOSZ.Add(vosz);
                    streamObject = reader.Read();
                }
                while (reader.RecordName == "VOSZ" || reader.RecordName == "VOSZ-v01");

                while (reader.RecordName == "DSKK" || reader.RecordName == "DSKK-v02")
                {
                    var record = Assert.IsType<DSKK02>(streamObject);
                    deuevMessage.DSKK.Add(record);
                    streamObject = reader.Read();
                }

                do
                {
                    var ncsz = Assert.IsType<NCSZ>(streamObject);
                    deuevMessage.NCSZ.Add(ncsz);
                    streamObject = reader.Read();
                }
                while (reader.RecordName != null && (reader.RecordName == "NCSZ-v01" || reader.RecordName == "NCSZ"));

                Assert.Null(reader.RecordName);
                Assert.Equal(deuevMessage.VOSZ.Count, deuevMessage.NCSZ.Count);

                return deuevMessage;
            }
            finally
            {
                reader.Close();
            }
        }
        /// <summary>
        /// Erstellt die Meldedatei anhand von <paramref name="data"/> neu.
        /// </summary>
        /// <param name="data">Die Daten die zur Erstellung der Meldedatei benutzt werden sollen</param>
        /// <param name="streamName">Der Name des Streams der für die Erstellung der Meldedatei benutzt werden soll</param>
        /// <returns>Die Meldedatei</returns>
        private string GetStringFromMessage(DeuevMessageData data, string streamName)
        {
            var output = new StringWriter();

            using (var writer = StreamFactory.CreateWriter(streamName, output))
            {
                foreach (var record in data.VOSZ)
                {
                    writer.Write(record);
                }
                foreach (var record in data.DSKK)
                {
                    writer.Write(record);
                }
                foreach (var record in data.NCSZ)
                {
                    writer.Write(record);
                }
            }
            return(output.ToString());
        }