iniCategorie.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace System.Fire.Ini {
  5. public class iniCategorie {
  6. private string _name;
  7. private List<iniValue> _values = new List<iniValue>();
  8. private iniHandle _Handle;
  9. private bool _hasChanged = false;
  10. public bool hasChanged {
  11. get { return _hasChanged; }
  12. set {
  13. this._Handle.hasChanged = value;
  14. _hasChanged = value;
  15. }
  16. }
  17. public iniCategorie(iniHandle Handler, string Name) {
  18. this._name = Name;
  19. this._Handle = Handler;
  20. this.hasChanged = true;
  21. this._Handle.hasChanged = true;
  22. }
  23. public iniValue this[string VariableName] {
  24. get { return this.Value(VariableName); }
  25. }
  26. public string Name {
  27. get { return this._name; }
  28. set {
  29. this.hasChanged = true;
  30. this._Handle.hasChanged = true;
  31. this._name = value;
  32. }
  33. }
  34. public override string ToString() {
  35. string tmp = "[" + this._name + "]";
  36. foreach (iniValue iv in this._values)
  37. tmp += "\r\n" + iv.ToString();
  38. return tmp;
  39. }
  40. public iniHandle Ini {
  41. get { return this._Handle; }
  42. }
  43. public bool HasValue(string ValueName) {
  44. foreach (iniValue ic in this._values)
  45. if (ic.Name.ToLower() == ValueName.ToLower())
  46. return true;
  47. return false;
  48. }
  49. public iniValue Value(string Name) {
  50. //System.Diagnostics.Debug.WriteLine("iniCategorie::Value('"+Name+"')");
  51. foreach (iniValue ic in this._values)
  52. if (ic.Name.ToLower() == Name.ToLower()) {
  53. //System.Diagnostics.Debug.WriteLine("Found Value");
  54. return ic;
  55. }
  56. //System.Diagnostics.Debug.WriteLine("Create Value");
  57. this._hasChanged = true;
  58. iniValue icn = new iniValue(this._Handle, this, Name);
  59. this._values.Add(icn);
  60. //System.Diagnostics.Debug.WriteLine("Value created: " + icn.Name);
  61. return icn;
  62. }
  63. public iniValue Value(int ID) {
  64. if (ID < this._values.Count)
  65. return this._values[ID];
  66. return null;
  67. }
  68. public iniValue Value(string Name, string Default) {
  69. foreach (iniValue ic in this._values)
  70. if (ic.Name.ToLower() == Name.ToLower())
  71. return ic;
  72. this._hasChanged = true;
  73. iniValue icn = new iniValue(this._Handle, this, Name);
  74. icn.Value = Default;
  75. this._values.Add(icn);
  76. return icn;
  77. }
  78. public iniValue Value(string Name, Int16 Default) {
  79. foreach (iniValue ic in this._values)
  80. if (ic.Name.ToLower() == Name.ToLower())
  81. return ic;
  82. this._hasChanged = true;
  83. iniValue icn = new iniValue(this._Handle, this, Name);
  84. icn.Int16 = Default;
  85. this._values.Add(icn);
  86. return icn;
  87. }
  88. public iniValue Value(string Name, Int32 Default) {
  89. foreach (iniValue ic in this._values)
  90. if (ic.Name.ToLower() == Name.ToLower())
  91. return ic;
  92. this._hasChanged = true;
  93. iniValue icn = new iniValue(this._Handle, this, Name);
  94. icn.Int32 = Default;
  95. this._values.Add(icn);
  96. return icn;
  97. }
  98. public iniValue Value(string Name, Int64 Default) {
  99. foreach (iniValue ic in this._values)
  100. if (ic.Name.ToLower() == Name.ToLower())
  101. return ic;
  102. this._hasChanged = true;
  103. iniValue icn = new iniValue(this._Handle, this, Name);
  104. icn.Int64 = Default;
  105. this._values.Add(icn);
  106. return icn;
  107. }
  108. public iniValue Value(string Name, bool Default) {
  109. foreach (iniValue ic in this._values)
  110. if (ic.Name.ToLower() == Name.ToLower()) {
  111. return ic;
  112. }
  113. this._hasChanged = true;
  114. iniValue icn = new iniValue(this._Handle, this, Name);
  115. icn.Bool = Default;
  116. this._values.Add(icn);
  117. return icn;
  118. }
  119. public iniValue Value(string Name, double Default) {
  120. foreach (iniValue ic in this._values)
  121. if (ic.Name.ToLower() == Name.ToLower())
  122. return ic;
  123. this._hasChanged = true;
  124. iniValue icn = new iniValue(this._Handle, this, Name);
  125. icn.Double = Default;
  126. this._values.Add(icn);
  127. return icn;
  128. }
  129. public iniValue Value(string Name, byte Default) {
  130. foreach (iniValue ic in this._values)
  131. if (ic.Name.ToLower() == Name.ToLower())
  132. return ic;
  133. this._hasChanged = true;
  134. iniValue icn = new iniValue(this._Handle, this, Name);
  135. icn.Byte = Default;
  136. this._values.Add(icn);
  137. return icn;
  138. }
  139. }
  140. }