コード例 #1
0
 public void ComponentNotClosed()
 {
     var settings = new IcsWriterSettings();
     var s = new StringWriter();
     var writer = IcsWriter.Create(s, settings);
     writer.WriteBeginComponent("A");
     writer.WriteBeginComponent("B");
     writer.WriteEndComponent();
     ExceptionAssert.Throws<CalendarException>(() => writer.Dispose());
 }
コード例 #2
0
 /// <summary>
 ///   A line must be folded when it greater octets per line.
 /// </summary>
 public void LineFolding2()
 {
     var line = new ContentLine("ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:mailto:[email protected]");
     var settings = new IcsWriterSettings();
     var s = new StringWriter();
     using (var writer = IcsWriter.Create(s, settings))
     {
         writer.Write(line);
     }
     var lines = s.ToString().Replace("\r\n", "\n").TrimEnd('\n').Split('\n');
     foreach (var l in lines)
         Assert.IsTrue(Encoding.UTF8.GetByteCount(l) <= settings.OctetsPerLine);
 }
コード例 #3
0
 public void LineFolding()
 {
     var line = new ContentLine("prop12;foo=1;bar=2:word1 word2");
     var settings = new IcsWriterSettings() { OctetsPerLine = 7 };
     var s = new StringWriter();
     using (var writer = IcsWriter.Create(s, settings))
     {
         writer.Write(line);
     }
     var ics = s.ToString().Replace("\r\n", "\n").TrimEnd('\n').Split('\n');
     Assert.AreEqual(5, ics.Length);
     Assert.AreEqual("PROP12;", ics[0]);
     Assert.AreEqual(" FOO=1;", ics[1]);
     Assert.AreEqual(" BAR=2:", ics[2]);
     Assert.AreEqual(" word1 ", ics[3]);
     Assert.AreEqual(" word2", ics[4]);
 }
コード例 #4
0
 /// <summary>
 ///   Converts the <see cref="CalendarAttachment"/> to a RFC 5545 line.
 /// </summary>
 /// <returns>
 ///   The iCalendar representation.
 /// </returns>
 /// <remarks>
 ///   Line folds are not applied.
 /// </remarks>
 public override string ToString()
 {
     var settings = new IcsWriterSettings() { OctetsPerLine = Int32.MaxValue };
     var s = new StringWriter();
     using (var writer = IcsWriter.Create(s, settings))
     {
         this.WriteIcs(writer);
     }
     return s.ToString().TrimEnd('\r', '\n');
 }
コード例 #5
0
        public void NestedComponents()
        {
            var settings = new IcsWriterSettings();
            var s = new StringWriter();
            using (var writer = IcsWriter.Create(s, settings))
            {
                writer.WriteBeginComponent("A");
                writer.WriteBeginComponent("B");
                writer.WriteEndComponent();
                writer.WriteEndComponent();
            }

            var ics = s.ToString().Replace("\r\n", "\n").TrimEnd('\n').Split('\n');
            Assert.AreEqual(4, ics.Length);
            Assert.AreEqual("BEGIN:A", ics[0]);
            Assert.AreEqual("BEGIN:B", ics[1]);
            Assert.AreEqual("END:B", ics[2]);
            Assert.AreEqual("END:A", ics[3]);
        }
コード例 #6
0
ファイル: IcsWriter.cs プロジェクト: richardschneider/sepia
 /// <summary>
 ///   Creates a new instance of the <see cref="IcsWriter"/> with the specified <see cref="TextWriter"/>
 ///   and <see cref="IcsWriterSettings"/>
 /// </summary>
 /// <param name="writer">
 ///   The <see cref="TextWriter"/> to write iCalendar data.
 /// </param>
 /// <param name="settings">
 ///   The <see cref="IcsWriterSettings"/> for the writer.
 /// </param>
 public static IcsWriter Create(TextWriter writer, IcsWriterSettings settings)
 {
     return new IcsWriter(writer, settings);
 }
コード例 #7
0
ファイル: IcsWriter.cs プロジェクト: richardschneider/sepia
 /// <summary>
 ///   Creates a new instance of the <see cref="IcsWriter"/> with the specified <see cref="TextWriter"/>.
 /// </summary>
 /// <param name="writer">
 ///   The <see cref="TextWriter"/> to write iCalendar data.
 /// </param>
 /// <param name="settings">
 ///   The <see cref="IcsWriterSettings"/> for the writer.
 /// </param>
 /// <remarks>
 ///   <see cref="TextWriter.NewLine"/> is set to "\r\n".
 /// </remarks>
 IcsWriter(TextWriter writer, IcsWriterSettings settings)
 {
     this.writer = writer;
     this.writer.NewLine = "\r\n";
     this.settings = settings;
 }