Blame view

Vrh.OneReport/XmlProcessing/PresetElement.cs 2.82 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.Log4Pro.MultiLanguageManager;
  using Vrh.XmlProcessing;
  using System.Collections.Generic;
  using System.Linq;
  
  namespace Vrh.OneReport
  {
      /// <summary>
      /// A "DefaultFormat" elemet reprezentáló osztály.
      /// "General" és "Report" elemben is előfordul.
      /// </summary>
      public class PresetElement : XmlLinqBase
      {
  		#region ElementNames static class
  		public new class ElementNames : XmlLinqBase.ElementNames
  		{
  			/// <summary>
  			/// 'CommonPresets' elem név.
  			/// </summary>
  			public const string PRESET = "Preset";
  		}
  		#endregion ElementNames static class
  
  		#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>
              /// 'DisplayName' attribútum név.
              /// </summary>
              public const string DISPLAYNAME = "DisplayName";
  
              /// <summary>
              /// 'Name' attribútum név.
              /// </summary>
              public const string ID = "Id";
          }
          #endregion AttributeNames static class
  
          #region Properties
  
          /// <summary>
          /// Preset azonosítója.
          /// </summary>
          public string Id { get; set; }
  
          /// <summary>
          /// Preset megnevezése (leírása).
          /// </summary>
          public string DisplayName { get; set; }
  
          #endregion Properties
  
          #region Constructor
          /// <summary>
          /// Példány létrehozása egy XElement alapján.
          /// </summary>
          /// <param name="xelement">A "Preset" elem.</param>
          public PresetElement(XElement xelement)
          {
              if (xelement != null)
              {
                  this.Id = GetValue(AttributeNames.ID, xelement, "", true, true);
  
                  this.DisplayName = GetValue(xelement.Attribute(AttributeNames.DISPLAYNAME), "");
              }
          }
  		#endregion Constructor
  
  		#region PresetElementList static constructor
  		/// <summary>
  		/// Egy preset xml elemlistát tartalmazó xml elemből előállítja a PresetElement listát
  		/// Ha nincs preset lista, akkor üres listával tér vissza
  		/// </summary>
  		/// <param name="presetlistContainerXelement"></param>
  		/// <returns></returns>
  		public static List<PresetElement> PresetElementList(XElement presetlistContainerXelement)
  		{
  			List<PresetElement> rl = new List<PresetElement>();
  			if (presetlistContainerXelement != null)
  			{
  				var presetsXmlList = presetlistContainerXelement.Elements(XName.Get(ElementNames.PRESET)).ToList();
  				if (presetsXmlList != null && presetsXmlList.Any())
  				{
  					foreach (var presetXE in presetsXmlList) { rl.Add(new PresetElement(presetXE)); }
  				}
  			}
  			return rl;
  		}
  		#endregion PresetElementList static constructor
  
  	}
  }