Esempio n. 1
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());
        }
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 <TEntity, TDocument>(this TEntity entity, IStonWriter <TEntity, TDocument> writer)
            where TEntity : IStonEntity
            where TDocument : IStonDocument
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            var stringWriter = new StringWriter();

            writer.WriteEntity(stringWriter, entity);
            return(stringWriter.ToString());
        }
Esempio n. 3
0
 /// <summary>
 /// Writes a string representation of a STON entity to a stream, using specific STON writer, leaving the stream open.
 /// </summary>
 /// <param name="entity">The entity 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 IStonEntity entity, 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.WriteEntity(streamWriter, entity);
     }
 }
Esempio n. 4
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);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Writes a string representation of a STON entity to a stream, using specific STON writer, leaving the stream open.
 /// </summary>
 /// <param name="entity">The entity 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 TEntity entity, 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.WriteEntity(streamWriter, entity);
     }
 }
Esempio n. 6
0
 public static void Save <TEntity, TDocument>(this TEntity entity, 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.WriteEntity(streamWriter, entity);
     }
 }