/* * File.Writer.cs * * Copyright © 2009 * Diversified Technical Systems, Inc. * All Rights Reserved */ using System.Text; using DTS.Common.Utilities; using DTS.Common.Utilities.DotNetProgrammingConstructs; namespace DTS.Serialization { // *** see File.cs *** public abstract partial class File { /// /// /// A class framework for a file writer. There can (and should) be several Write methods, one for /// each type that can be written into the file format. But it must have at least one, /// and that's what's outlined by this base implementation. /// /// /// /// The file type that this writer belongs to. /// /// public abstract partial class Writer : Exceptional, IWriter where T : File { protected int _defaultEncoding = Encoding.UTF8.CodePage; public virtual int DefaultEncoding { get => _defaultEncoding; set => _defaultEncoding = value; } /// /// /// Initialize an instance of the DTS.Serialization.File.Writer class. This one-and-only /// constructor is marked as "internal", implying that these types of object should only /// be created by some factory method (intended to be in the hosting File object) and /// then passed to the user. /// /// /// /// The associated -based class. /// /// public Writer(T fileType, int encoding) { try { FileType = fileType; DefaultEncoding = encoding; } catch (System.Exception ex) { throw new Exception("encountered problem constructing " + GetType().FullName, ex); } } /// /// Get the -type associated with this reader. /// protected T FileType { get => _FileType.Value; private set => _FileType.Value = value; } private readonly Property _FileType = new Property( typeof(Reader).Namespace + ".File.Reader.FileType", null, false ); } } }