9 public class ArrayList : Dictionary<object, object>
12 #region Private Methods
14 private void OutputValue(StringBuilder stringBuilder,
object objectValue)
17 if (objectValue.GetType() != typeof(
ArrayList))
18 stringBuilder.Append(
"\"" + objectValue +
"\"");
21 stringBuilder.Append(objectValue);
27 private bool EqualValues(
object objectValue1,
object objectValue2)
30 Type type1 = objectValue1.GetType();
32 Type type2 = objectValue2.GetType();
34 if (type1 == typeof(
int) && type2 == typeof(
int))
35 return (
int)objectValue1 == (int)objectValue2;
37 else if (type1 == typeof(
int) && type2 == typeof(
float))
38 return (
int)objectValue1 == (float)objectValue2;
40 else if (type1 == typeof(
float) && type2 == typeof(
int))
41 return (
float)objectValue1 == (int)objectValue2;
43 else if (type1 == typeof(
float) && type2 == typeof(
float))
44 return (
float)objectValue1 == (float)objectValue2;
46 else if (type1 == typeof(
string) || type2 == typeof(
string))
47 return objectValue1.
ToString() == objectValue2.ToString();
49 else return objectValue1 == objectValue2;
53 private void AddValue(
object objectValue)
56 while (ContainsKey(iIndex)) ++iIndex;
57 this[iIndex] = objectValue;
60 private void SubtractValue(
object objectValue)
62 List<object> listValues =
new List<object>();
63 foreach (
object objectOldValue
in Values)
65 if (!EqualValues(objectOldValue, objectValue)) listValues.Add(objectOldValue);
69 foreach (
object objectOldValue
in listValues)
71 this[iIndex++] = objectOldValue;
75 private void AddArray(
ArrayList assocativeArray)
78 while (ContainsKey(iIndex)) ++iIndex;
79 foreach (
object objectValue
in assocativeArray.Values)
81 this[iIndex++] = objectValue;
85 private void SubtractArray(
ArrayList associativeArray)
87 foreach (
object objectValue
in associativeArray.Values)
88 SubtractValue(objectValue);
93 #region Public Methods
95 public void Add(
object objectValue)
98 if (objectValue.GetType() == typeof(
ArrayList))
102 AddValue(objectValue);
109 if (objectValue.GetType() == typeof(
ArrayList))
112 else SubtractValue(objectValue);
118 string culture = Thread.CurrentThread.CurrentCulture.NumberFormat.PercentDecimalSeparator;
119 string decimalSeparator =
",";
121 StringBuilder stringBuilder =
new StringBuilder();
122 stringBuilder.Append(
"{ ");
124 foreach (
object objectKey
in Keys)
126 if (!bFirst) stringBuilder.Append(decimalSeparator +
" ");
128 OutputValue(stringBuilder, objectKey);
129 stringBuilder.Append(
": ");
130 OutputValue(stringBuilder,
this[objectKey]);
132 stringBuilder.Append(
" }");
133 return stringBuilder.ToString();
138 #region Public Properties
140 public new object this[
object objectKey]
146 if (objectKey.GetType() == typeof(
string) && ((
string)objectKey) ==
"size")
149 if (!ContainsKey(objectKey))
150 return NullReference.Instance;
152 return base[objectKey];
158 if (objectKey ==
null)
159 objectKey = NullReference.Instance;
161 if (objectKey.GetType() == typeof(
string) && ((
string)objectKey) ==
"size")
162 throw new ExecutionException(
"Der Member 'size' eines Arrays ist eine 'read-only' Eigenschaft.");
165 base[objectKey] = NullReference.Instance;
168 base[objectKey] = value;