Blame view

Vrh.OneReport/XmlProcessing/DefaultFormatElement.cs 3.04 KB
ab9f2fbe   Schwirg László   Add project files.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
  using System.Xml.Linq;
  
  using Vrh.XmlProcessing;
  
  namespace Vrh.OneReport
  {
      /// <summary>
      /// A "DefaultFormat" elemet reprezentáló osztály.
      /// "General" és "Report" elemben is előfordul.
      /// </summary>
      public class FormatElement : XmlLinqBase
      {
          #region AttributeNames static class
          /// <summary>
          /// Az XML fájlban ilyen attribútum nevek találhatóak egy "Output" elemben.
          /// </summary>
          public static class AttributeNames
          {
              /// <summary>
              /// 'action' attribútum név.
              /// </summary>
              public const string EXPORT = "Export";
  
              /// <summary>
              /// 'file' attribútum név.
              /// </summary>
              public const string FILE = "File";
          }
  		#endregion AttributeNames static class
  
  		#region Properties
  		/// <summary>
  		/// Exportok alapértelmezett formátuma.
  		/// Alapértelmezés: CSV
  		/// </summary>
  		public AllFormats AllFormats { get; set; } = AllFormats.PDF;
  
  
  		/// <summary>
  		/// Exportok alapértelmezett formátuma.
  		/// Alapértelmezés: CSV
  		/// </summary>
  		public ExportFormats Export { get; set; } = ExportFormats.CSV;
  
          /// <summary>
          /// Fájlba történő output esetén az alapértelmezett formátum.
          /// Alapértelmezés: PDF
          /// </summary>
          public ToFileFormats File { get; set; } = ToFileFormats.PDF;
  
          #endregion Properties
  
          #region Constructor
          /// <summary>
          /// Példány létrehozása egy XElement alapján.
          /// </summary>
          /// <param name="xelement">A "DefaultFormat" elem.</param>
          /// <param name="defaultFormat">
          /// Egy FormatElement objektum, mely alapértelmezett értékeket tartalmaz.
          /// </param>
          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
      }
  }