4 namespace HKI.Core.Variables
8 [CreateAssetMenu(fileName =
"Date", menuName =
"HKI/Variables/Date", order = 20)]
14 return Value.ValidateDay();
17 public override void Save(XmlNode parentNode)
19 XmlNode node = parentNode.OwnerDocument.CreateElement(name.Replace(
" ",
""));
20 parentNode.AppendChild(node);
22 XmlAttribute valueDayAttribute = parentNode.OwnerDocument.CreateAttribute(
"Day");
23 valueDayAttribute.Value = Value.Day.ToString();
24 node.Attributes.Append(valueDayAttribute);
26 XmlAttribute valueMonthAttribute = parentNode.OwnerDocument.CreateAttribute(
"Month");
27 valueMonthAttribute.Value = Value.Month.ToString();
28 node.Attributes.Append(valueMonthAttribute);
30 XmlAttribute valueYearAttribute = parentNode.OwnerDocument.CreateAttribute(
"Year");
31 valueYearAttribute.Value = Value.Year.ToString();
32 node.Attributes.Append(valueYearAttribute);
34 XmlAttribute valueBCADAttribute = parentNode.OwnerDocument.CreateAttribute(
"BCAD");
35 valueBCADAttribute.Value = Value.BCAD.ToString();
36 node.Attributes.Append(valueBCADAttribute);
39 public override void Load(XmlNode node)
41 if (node.Attributes == null)
43 Debug.LogError(
"(Date) >" + name +
"< Loading failed because this XmlNode has not attributes!");
47 XmlAttribute valueDayAttribute = node.Attributes[
"Day"];
48 if(valueDayAttribute == null)
50 Debug.LogError(
"(Date) >" + name +
"< Loading failed because this XmlNode has not an attribute with the name >Day<!");
54 XmlAttribute valueMonthAttribute = node.Attributes[
"Month"];
55 if(valueMonthAttribute == null)
57 Debug.LogError(
"(Date) >" + name +
"< Loading failed because this XmlNode has not an attribute with the name >Month<!");
61 XmlAttribute valueYearAttribute = node.Attributes[
"Year"];
62 if(valueYearAttribute == null)
64 Debug.LogError(
"(Date) >" + name +
"< Loading failed because this XmlNode has not an attribute with the name >Year<!");
68 XmlAttribute valueBCADAttribute = node.Attributes[
"BCAD"];
69 if(valueBCADAttribute == null)
71 Debug.LogError(
"(Date) >" + name +
"< Loading failed because this XmlNode has not an attribute with the name >BCAD<!");
76 if (!
int.TryParse(valueDayAttribute.Value, out parsedDayValue))
77 Debug.LogError(
"(Date) >" + name +
"< Loading failed because parsing of >" + valueDayAttribute.Value +
"< failed!");
80 if (!
System.Enum.TryParse(valueMonthAttribute.Value, out parsedMonthValue))
81 Debug.LogError(
"(Date) >" + name +
"< Loading failed because parsing of >" + valueMonthAttribute.Value +
"< failed!");
84 if (!
int.TryParse(valueYearAttribute.Value, out parsedYearValue))
85 Debug.LogError(
"(Date) >" + name +
"< Loading failed because parsing of >" + valueYearAttribute.Value +
"< failed!");
88 if (!
System.Enum.TryParse(valueBCADAttribute.Value, out parsedBCADValue))
89 Debug.LogError(
"(Date) >" + name +
"< Loading failed because parsing of >" + valueBCADAttribute.Value +
"< failed!");
91 SetValue =
new DayMonthYear(parsedDayValue, parsedMonthValue, parsedYearValue, parsedBCADValue);
override void Load(XmlNode node)
override void Save(XmlNode parentNode)
This class adds a generic implementation to HKIVar. This reduces the repetitive implementation of thi...