using System.Xml.Linq; using Vrh.XmlProcessing; namespace Vrh.OneReport { /// /// A "DefaultFormat" elemet reprezentáló osztály. /// "General" és "Report" elemben is előfordul. /// public class FormatElement : XmlLinqBase { #region AttributeNames static class /// /// Az XML fájlban ilyen attribútum nevek találhatóak egy "Output" elemben. /// public static class AttributeNames { /// /// 'action' attribútum név. /// public const string EXPORT = "Export"; /// /// 'file' attribútum név. /// public const string FILE = "File"; } #endregion AttributeNames static class #region Properties /// /// Exportok alapértelmezett formátuma. /// Alapértelmezés: CSV /// public AllFormats AllFormats { get; set; } = AllFormats.PDF; /// /// Exportok alapértelmezett formátuma. /// Alapértelmezés: CSV /// public ExportFormats Export { get; set; } = ExportFormats.CSV; /// /// Fájlba történő output esetén az alapértelmezett formátum. /// Alapértelmezés: PDF /// public ToFileFormats File { get; set; } = ToFileFormats.PDF; #endregion Properties #region Constructor /// /// Példány létrehozása egy XElement alapján. /// /// A "DefaultFormat" elem. /// /// Egy FormatElement objektum, mely alapértelmezett értékeket tartalmaz. /// public FormatElement(XElement xelement, FormatElement defaultFormat = null) { if (xelement != null) { this.Export = GetEnumValue( xelement.Attribute(AttributeNames.EXPORT), defaultFormat == null ? ExportFormats.CSV : defaultFormat.Export ); switch (this.Export) { case ExportFormats.XML: this.AllFormats = AllFormats.XML; break; case ExportFormats.CSV: this.AllFormats = AllFormats.CSV; break; } this.File = GetEnumValue( xelement.Attribute(AttributeNames.FILE), defaultFormat == null ? ToFileFormats.PDF : defaultFormat.File ); switch (this.File) { case ToFileFormats.PDF: this.AllFormats = AllFormats.PDF;break; case ToFileFormats.DOC: this.AllFormats = AllFormats.DOC; break; case ToFileFormats.XLS: this.AllFormats = AllFormats.XLS; break; } } else { if (defaultFormat != null) { this.Export = defaultFormat.Export; this.File = defaultFormat.File; this.AllFormats = defaultFormat.AllFormats; } } } #endregion Constructor } }