wasSharp – Diff between revs 27 and 39

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 27 Rev 39
1 /////////////////////////////////////////////////////////////////////////// 1 ///////////////////////////////////////////////////////////////////////////
2 // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // 2 // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 //
3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // 3 // Please see: http://www.gnu.org/licenses/gpl.html for legal details, //
4 // rights of fair usage, the disclaimer and warranty conditions. // 4 // rights of fair usage, the disclaimer and warranty conditions. //
5 /////////////////////////////////////////////////////////////////////////// 5 ///////////////////////////////////////////////////////////////////////////
6 // Based on the work of Herman Schoenfeld 6 // Based on the work of Herman Schoenfeld
7   -  
8 using System; 7  
9 using System.Collections.Generic; 8 using System.Collections.Generic;
-   9 using System.Linq;
10 using System.Linq; 10 using System.Threading;
11   11  
12 namespace wasSharp.Collections.Specialized 12 namespace wasSharp.Collections.Specialized
13 { 13 {
14 public class MultiKeyDictionary<K1, K2, V> : Dictionary<K1, Dictionary<K2, V>> 14 public class MultiKeyDictionary<K1, K2, V> : Dictionary<K1, Dictionary<K2, V>>
15 { 15 {
-   16 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   17  
16 public V this[K1 key1, K2 key2] 18 public V this[K1 key1, K2 key2]
17 { 19 {
18 get 20 get
19 { 21 {
-   22 SyncRoot.EnterReadLock();
20 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) 23 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2))
-   24 {
-   25 SyncRoot.ExitReadLock();
21 throw new ArgumentOutOfRangeException(); 26 return default(V);
-   27 }
22 return base[key1][key2]; 28 var v = base[key1][key2];
-   29 SyncRoot.ExitReadLock();
-   30 return v;
23 } 31 }
24 set 32 set
25 { 33 {
-   34 SyncRoot.EnterWriteLock();
26 if (!ContainsKey(key1)) 35 if (!ContainsKey(key1))
27 this[key1] = new Dictionary<K2, V>(); 36 this[key1] = new Dictionary<K2, V>();
-   37  
28 this[key1][key2] = value; 38 this[key1][key2] = value;
-   39 SyncRoot.ExitWriteLock();
29 } 40 }
30 } 41 }
31   42  
-   43 public new IEnumerable<V> Values
-   44 {
-   45 get
-   46 {
32 public new IEnumerable<V> Values => 47 SyncRoot.EnterReadLock();
-   48 var v = base.Values.SelectMany(baseDict => baseDict.Keys, (baseDict, baseKey) => baseDict[baseKey]);
-   49 SyncRoot.ExitReadLock();
-   50 return v;
-   51 }
33 base.Values.SelectMany(baseDict => baseDict.Keys, (baseDict, baseKey) => baseDict[baseKey]); 52 }
34   53  
35 public void Add(K1 key1, K2 key2, V value) 54 public void Add(K1 key1, K2 key2, V value)
36 { 55 {
-   56 SyncRoot.EnterWriteLock();
37 if (!ContainsKey(key1)) 57 if (!ContainsKey(key1))
38 this[key1] = new Dictionary<K2, V>(); 58 this[key1] = new Dictionary<K2, V>();
-   59  
39 this[key1][key2] = value; 60 this[key1][key2] = value;
-   61 SyncRoot.ExitWriteLock();
40 } 62 }
41   63  
42 public void Remove(K1 key1, K2 key2) 64 public void Remove(K1 key1, K2 key2)
43 { 65 {
-   66 SyncRoot.EnterWriteLock();
44 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) 67 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2))
-   68 {
-   69 SyncRoot.ExitWriteLock();
45 return; 70 return;
-   71 }
46 this[key1].Remove(key2); 72 this[key1].Remove(key2);
47 Remove(key1); 73 Remove(key1);
-   74 SyncRoot.ExitWriteLock();
48 } 75 }
49   76  
50 public bool ContainsKey(K1 key1, K2 key2) 77 public bool ContainsKey(K1 key1, K2 key2)
51 { 78 {
-   79 SyncRoot.EnterReadLock();
52 return ContainsKey(key1) && this[key1].ContainsKey(key2); 80 var c = ContainsKey(key1) && this[key1].ContainsKey(key2);
-   81 SyncRoot.ExitReadLock();
-   82 return c;
53 } 83 }
54   84  
55 public bool TryGetValue(K1 key1, K2 key2, out V value) 85 public bool TryGetValue(K1 key1, K2 key2, out V value)
56 { 86 {
-   87 SyncRoot.EnterReadLock();
57 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) 88 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2))
58 { 89 {
-   90 SyncRoot.ExitReadLock();
59 value = default(V); 91 value = default(V);
60 return false; 92 return false;
61 } 93 }
62 value = base[key1][key2]; 94 value = base[key1][key2];
-   95 SyncRoot.ExitReadLock();
63 return true; 96 return true;
64 } 97 }
65 } 98 }
66   99  
67 public class MultiKeyDictionary<K1, K2, K3, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, V>> 100 public class MultiKeyDictionary<K1, K2, K3, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, V>>
68 { 101 {
-   102 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   103  
69 public V this[K1 key1, K2 key2, K3 key3] 104 public V this[K1 key1, K2 key2, K3 key3]
70 { 105 {
-   106 get
-   107 {
-   108 SyncRoot.EnterReadLock();
71 get { return ContainsKey(key1) ? this[key1][key2, key3] : default(V); } 109 var v = ContainsKey(key1) ? this[key1][key2, key3] : default(V);
-   110 SyncRoot.ExitReadLock();
-   111 return v;
-   112 }
72 set 113 set
73 { 114 {
-   115 SyncRoot.EnterWriteLock();
74 if (!ContainsKey(key1)) 116 if (!ContainsKey(key1))
75 this[key1] = new MultiKeyDictionary<K2, K3, V>(); 117 this[key1] = new MultiKeyDictionary<K2, K3, V>();
76 this[key1][key2, key3] = value; 118 this[key1][key2, key3] = value;
-   119 SyncRoot.ExitWriteLock();
77 } 120 }
78 } 121 }
79   122  
80 public bool ContainsKey(K1 key1, K2 key2, K3 key3) 123 public bool ContainsKey(K1 key1, K2 key2, K3 key3)
81 { 124 {
-   125 SyncRoot.EnterReadLock();
82 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3); 126 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3);
-   127 SyncRoot.ExitReadLock();
-   128 return c;
83 } 129 }
84   130  
85 public void Add(K1 key1, K2 key2, K3 key3, V value) 131 public void Add(K1 key1, K2 key2, K3 key3, V value)
86 { 132 {
-   133 SyncRoot.EnterWriteLock();
87 if (!ContainsKey(key1)) 134 if (!ContainsKey(key1))
88 this[key1] = new MultiKeyDictionary<K2, K3, V>(); 135 this[key1] = new MultiKeyDictionary<K2, K3, V>();
89 this[key1][key2, key3] = value; 136 this[key1][key2, key3] = value;
-   137 SyncRoot.ExitWriteLock();
90 } 138 }
91   139  
92 public void Remove(K1 key1, K2 key2, K3 key3) 140 public void Remove(K1 key1, K2 key2, K3 key3)
93 { 141 {
-   142 SyncRoot.EnterWriteLock();
94 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3)) 143 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3))
-   144 {
-   145 SyncRoot.ExitWriteLock();
95 return; 146 return;
-   147 }
96 this[key1][key2].Remove(key3); 148 this[key1][key2].Remove(key3);
97 this[key1].Remove(key2); 149 this[key1].Remove(key2);
98 Remove(key1); 150 Remove(key1);
-   151 SyncRoot.ExitWriteLock();
99 } 152 }
100   153  
101 public bool TryGetValue(K1 key1, K2 key2, K3 key3, out V value) 154 public bool TryGetValue(K1 key1, K2 key2, K3 key3, out V value)
102 { 155 {
-   156 SyncRoot.EnterReadLock();
103 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3)) 157 if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3))
104 { 158 {
-   159 SyncRoot.ExitReadLock();
105 value = default(V); 160 value = default(V);
106 return false; 161 return false;
107 } 162 }
108 value = base[key1][key2, key3]; 163 value = base[key1][key2, key3];
-   164 SyncRoot.ExitReadLock();
109 return true; 165 return true;
110 } 166 }
111 } 167 }
112   168  
113 public class MultiKeyDictionary<K1, K2, K3, K4, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, V>> 169 public class MultiKeyDictionary<K1, K2, K3, K4, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, V>>
114 { 170 {
-   171 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   172  
115 public V this[K1 key1, K2 key2, K3 key3, K4 key4] 173 public V this[K1 key1, K2 key2, K3 key3, K4 key4]
116 { 174 {
-   175 get
-   176 {
-   177 SyncRoot.EnterReadLock();
117 get { return ContainsKey(key1) ? this[key1][key2, key3, key4] : default(V); } 178 var v = ContainsKey(key1) ? this[key1][key2, key3, key4] : default(V);
-   179 SyncRoot.ExitReadLock();
-   180 return v;
-   181 }
118 set 182 set
119 { 183 {
-   184 SyncRoot.EnterWriteLock();
120 if (!ContainsKey(key1)) 185 if (!ContainsKey(key1))
121 this[key1] = new MultiKeyDictionary<K2, K3, K4, V>(); 186 this[key1] = new MultiKeyDictionary<K2, K3, K4, V>();
122 this[key1][key2, key3, key4] = value; 187 this[key1][key2, key3, key4] = value;
-   188 SyncRoot.ExitWriteLock();
123 } 189 }
124 } 190 }
125   191  
126 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4) 192 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4)
127 { 193 {
-   194 SyncRoot.EnterReadLock();
128 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4); 195 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4);
-   196 SyncRoot.ExitReadLock();
-   197 return c;
129 } 198 }
130 } 199 }
131   200  
132 public class MultiKeyDictionary<K1, K2, K3, K4, K5, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, V>> 201 public class MultiKeyDictionary<K1, K2, K3, K4, K5, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, V>>
133 { 202 {
-   203 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   204  
134 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5] 205 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5]
135 { 206 {
-   207 get
-   208 {
-   209 SyncRoot.EnterReadLock();
136 get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5] : default(V); } 210 var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5] : default(V);
-   211 SyncRoot.ExitReadLock();
-   212 return v;
-   213 }
137 set 214 set
138 { 215 {
-   216 SyncRoot.EnterWriteLock();
139 if (!ContainsKey(key1)) 217 if (!ContainsKey(key1))
140 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, V>(); 218 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, V>();
141 this[key1][key2, key3, key4, key5] = value; 219 this[key1][key2, key3, key4, key5] = value;
-   220 SyncRoot.ExitWriteLock();
142 } 221 }
143 } 222 }
144   223  
145 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5) 224 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5)
146 { 225 {
-   226 SyncRoot.EnterReadLock();
147 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5); 227 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5);
-   228 SyncRoot.ExitReadLock();
-   229 return c;
148 } 230 }
149 } 231 }
150   232  
151 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, V> : 233 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, V> :
152 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, V>> 234 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, V>>
153 { 235 {
-   236 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   237  
154 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6] 238 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6]
155 { 239 {
-   240 get
-   241 {
-   242 SyncRoot.EnterReadLock();
156 get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6] : default(V); } 243 var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6] : default(V);
-   244 SyncRoot.ExitReadLock();
-   245 return v;
-   246 }
157 set 247 set
158 { 248 {
-   249 SyncRoot.EnterWriteLock();
159 if (!ContainsKey(key1)) 250 if (!ContainsKey(key1))
160 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, V>(); 251 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, V>();
161 this[key1][key2, key3, key4, key5, key6] = value; 252 this[key1][key2, key3, key4, key5, key6] = value;
-   253 SyncRoot.ExitWriteLock();
162 } 254 }
163 } 255 }
164   256  
165 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6) 257 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6)
166 { 258 {
-   259 SyncRoot.EnterReadLock();
167 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6); 260 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6);
-   261 SyncRoot.ExitReadLock();
-   262 return c;
168 } 263 }
169 } 264 }
170   265  
171 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, V> : 266 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, V> :
172 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>> 267 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>>
173 { 268 {
-   269 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   270  
174 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7] 271 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7]
175 { 272 {
-   273 get
-   274 {
-   275 SyncRoot.EnterReadLock();
176 get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7] : default(V); } 276 var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7] : default(V);
-   277 SyncRoot.ExitReadLock();
-   278 return v;
-   279 }
177 set 280 set
178 { 281 {
-   282 SyncRoot.EnterWriteLock();
179 if (!ContainsKey(key1)) 283 if (!ContainsKey(key1))
180 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>(); 284 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>();
181 this[key1][key2, key3, key4, key5, key6, key7] = value; 285 this[key1][key2, key3, key4, key5, key6, key7] = value;
-   286 SyncRoot.ExitWriteLock();
182 } 287 }
183 } 288 }
184   289  
185 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7) 290 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7)
186 { 291 {
-   292 SyncRoot.EnterReadLock();
187 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7); 293 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7);
-   294 SyncRoot.ExitReadLock();
-   295 return c;
188 } 296 }
189 } 297 }
190   298  
191 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, V> : 299 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, V> :
192 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>> 300 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>>
193 { 301 {
-   302 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   303  
194 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8] 304 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8]
195 { 305 {
-   306 get
-   307 {
-   308 SyncRoot.EnterReadLock();
196 get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8] : default(V); } 309 var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8] : default(V);
-   310 SyncRoot.ExitReadLock();
-   311 return v;
-   312 }
197 set 313 set
198 { 314 {
-   315 SyncRoot.EnterWriteLock();
199 if (!ContainsKey(key1)) 316 if (!ContainsKey(key1))
200 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>(); 317 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>();
201 this[key1][key2, key3, key4, key5, key6, key7, key8] = value; 318 this[key1][key2, key3, key4, key5, key6, key7, key8] = value;
-   319 SyncRoot.ExitWriteLock();
202 } 320 }
203 } 321 }
204   322  
205 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8) 323 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8)
206 { 324 {
-   325 SyncRoot.EnterReadLock();
207 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8); 326 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8);
-   327 SyncRoot.ExitReadLock();
-   328 return c;
208 } 329 }
209 } 330 }
210   331  
211 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, V> : 332 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, V> :
212 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>> 333 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>>
213 { 334 {
-   335 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   336  
214 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9] 337 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9]
215 { 338 {
-   339 get
-   340 {
-   341 SyncRoot.EnterReadLock();
216 get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9] : default(V); } 342 var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9] : default(V);
-   343 SyncRoot.ExitReadLock();
-   344 return v;
-   345 }
217 set 346 set
218 { 347 {
-   348 SyncRoot.EnterWriteLock();
219 if (!ContainsKey(key1)) 349 if (!ContainsKey(key1))
220 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>(); 350 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>();
221 this[key1][key2, key3, key4, key5, key6, key7, key8, key9] = value; 351 this[key1][key2, key3, key4, key5, key6, key7, key8, key9] = value;
-   352 SyncRoot.ExitWriteLock();
222 } 353 }
223 } 354 }
224   355  
225 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9) 356 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9)
226 { 357 {
-   358 SyncRoot.EnterReadLock();
227 return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9); 359 var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9);
-   360 SyncRoot.ExitReadLock();
-   361 return c;
228 } 362 }
229 } 363 }
230   364  
231 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, V> : 365 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, V> :
232 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>> 366 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>>
233 { 367 {
-   368 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   369  
234 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10] 370 public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10]
235 { 371 {
236 get 372 get
237 { 373 {
-   374 SyncRoot.EnterReadLock();
238 return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] : default(V); 375 var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] : default(V);
-   376 SyncRoot.ExitReadLock();
-   377 return v;
239 } 378 }
240 set 379 set
241 { 380 {
-   381 SyncRoot.EnterWriteLock();
242 if (!ContainsKey(key1)) 382 if (!ContainsKey(key1))
243 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>(); 383 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>();
244 this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] = value; 384 this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] = value;
-   385 SyncRoot.ExitWriteLock();
245 } 386 }
246 } 387 }
247   388  
248 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, 389 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9,
249 K10 key10) 390 K10 key10)
250 { 391 {
-   392 SyncRoot.EnterReadLock();
251 return ContainsKey(key1) && 393 var c = ContainsKey(key1) &&
252 this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10); 394 this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10);
-   395 SyncRoot.ExitReadLock();
-   396 return c;
253 } 397 }
254 } 398 }
255   399  
256 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V> : 400 public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V> :
257 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>> 401 Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>>
258 { 402 {
-   403 private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
-   404  
259 public V this[ 405 public V this[
260 K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10, K11 key11] 406 K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10, K11 key11]
261 { 407 {
262 get 408 get
263 { 409 {
-   410 SyncRoot.EnterReadLock();
264 return ContainsKey(key1) 411 var v = ContainsKey(key1)
265 ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10, key11] 412 ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10, key11]
266 : default(V); 413 : default(V);
-   414 SyncRoot.ExitReadLock();
-   415 return v;
267 } 416 }
268 set 417 set
269 { 418 {
-   419 SyncRoot.EnterWriteLock();
270 if (!ContainsKey(key1)) 420 if (!ContainsKey(key1))
271 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>(); 421 this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>();
272 this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10, key11] = value; 422 this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10, key11] = value;
-   423 SyncRoot.ExitWriteLock();
273 } 424 }
274 } 425 }
275   426  
276 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, 427 public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9,
277 K10 key10, K11 key11) 428 K10 key10, K11 key11)
278 { 429 {
-   430 SyncRoot.EnterReadLock();
279 return ContainsKey(key1) && 431 var c = ContainsKey(key1) &&
280 this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10, key11); 432 this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10, key11);
-   433 SyncRoot.ExitReadLock();
-   434 return c;
281 } 435 }
282 } 436 }
283 } 437 }
284   438