/// <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());
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a string representation of a STON entity, using specific STON writer.
        /// </summary>
        /// <param name="entity">The entity 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 IStonEntity entity, IStonWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            var stringWriter = new StringWriter();

            writer.WriteEntity(stringWriter, entity);
            return(stringWriter.ToString());
        }
        /// <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());
        }
 /// <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);
     }
 }
 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);
     }
 }
Esempio n. 6
0
 public static void Save(this IStonEntity entity, 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.WriteEntity(streamWriter, entity);
     }
 }
 /// <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);
     }
 }
 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);
     }
 }