Exemplo n.º 1
0
        /// <summary>
        /// Returns a string representation of a STON document, using specific STON writer.
        /// </summary>
        /// <param name="document">The document to represent as a string.</param>
        /// <param name="writer">The writer used to represent the entity.</param>
        /// <returns>The string representation of the entity.</returns>
        public static string ToString(this IStonDocument document, IStonWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            var stringWriter = new StringWriter();

            writer.WriteDocument(stringWriter, document);
            return(stringWriter.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a string representation of a STON document, using specific STON writer.
        /// </summary>
        /// <param name="document">The document to represent as a string.</param>
        /// <param name="writer">The writer used to represent the entity.</param>
        /// <returns>The string representation of the entity.</returns>
        public static string ToString <TEntity, TDocument>(this TDocument document, IStonWriter <TEntity, TDocument> writer)
            where TEntity : IStonEntity
            where TDocument : IStonDocument
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            var stringWriter = new StringWriter();

            writer.WriteDocument(stringWriter, document);
            return(stringWriter.ToString());
        }
Exemplo n.º 3
0
 /// <summary>
 /// Writes a string representation of a STON document to a stream, using specific STON writer, leaving the stream open.
 /// </summary>
 /// <param name="document">The document to write.</param>
 /// <param name="stream">The stream to write to.</param>
 /// <param name="writer">The writer used to write the entity.</param>
 public static void Save(this IStonDocument document, Stream stream, IStonWriter writer)
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     using (var streamWriter = new StreamWriter(stream, new UTF8Encoding(false, true), 1024, true))
     {
         writer.WriteDocument(streamWriter, document);
     }
 }
Exemplo n.º 4
0
 public static void Save(this IStonDocument document, string path, IStonWriter writer)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     using (var streamWriter = new StreamWriter(path))
     {
         writer.WriteDocument(streamWriter, document);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Writes a string representation of a STON document to a stream, using specific STON writer, leaving the stream open.
 /// </summary>
 /// <param name="document">The document to write.</param>
 /// <param name="stream">The stream to write to.</param>
 /// <param name="writer">The writer used to write the entity.</param>
 public static void Save <TEntity, TDocument>(this TDocument document, Stream stream, IStonWriter <TEntity, TDocument> writer)
     where TEntity : IStonEntity
     where TDocument : IStonDocument
 {
     if (stream == null)
     {
         throw new ArgumentNullException("stream");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     using (var streamWriter = new StreamWriter(stream, new UTF8Encoding(false, true), 1024, true))
     {
         writer.WriteDocument(streamWriter, document);
     }
 }
Exemplo n.º 6
0
 public static void Save <TEntity, TDocument>(this TDocument document, string path, IStonWriter <TEntity, TDocument> writer)
     where TEntity : IStonEntity
     where TDocument : IStonDocument
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     using (var streamWriter = new StreamWriter(path))
     {
         writer.WriteDocument(streamWriter, document);
     }
 }