Exemple #1
0
 /// <summary>
 /// Prepares a serializer and deserializer that work on a file.
 /// <para>
 /// Do not forget to call Dispose() when you release UniversalSerializer, or to write using(). Otherwize an IO exception could occure when trying to access the file for the second time, saying the file can not be open (in fact the file would have not been closed by this first instance of UniversalSerializer).
 /// </para>
 /// </summary>
 /// <param name="FileName">Creates or open this file.</param>
 /// <param name="formatter">The stream format.</param>
 public UniversalSerializer(
     string FileName, SerializerFormatters formatter)
     : this(new Parameters() { Stream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite), SerializerFormatter = formatter })
 {
     this.FileStreamCreatedByConstructorOnly = (FileStream)this.parameters.Stream;             // For Dispose().
 }
Exemple #2
0
        // - - - -

        /// <summary>
        /// Prepares a serializer and deserializer that work on a stream.
        /// </summary>
        /// <param name="stream">Your stream.</param>
        /// <param name="formatter">The stream format.</param>
        public UniversalSerializer(
            Stream stream, SerializerFormatters formatter)
            : this(new Parameters() { Stream = stream, SerializerFormatter = formatter })
        {
        }