public void Serialize(CalendarFile calendarFile, Stream outStream)
        {
            // get the content as string (unicode)
            string unfoldedContent = calendarFile.Serialize();

            // fold the unfolded content
            var foldedContent = FoldHelper.FoldContent(unfoldedContent);

            // convert unicode string to UTF-8 bytes
            var unicodeBytes = Encoding.Default.GetBytes(foldedContent);
            var utf8Bytes    = Encoding.Convert(Encoding.Default, Encoding.UTF8, unicodeBytes);

            // write the bytes to the output file
            using (var writer = new BinaryWriter(outStream))
            {
                writer.Write(utf8Bytes);
            }
        }
        public CalendarFile Deserialize(Stream inStream)
        {
            string foldedContent;

            // read text from stream (converts UTF-8 to Unicode)
            using (var reader = new StreamReader(inStream, Encoding.UTF8))
            {
                foldedContent = reader.ReadToEnd();
            }

            // unfold content
            string unfoldedContent = FoldHelper.UnfoldContent(foldedContent);

            // parse content and retrieve the object tree
            var calendar = ObjectSerializer.Deserialize <CalendarFile>(unfoldedContent);

            return(calendar);
        }