9using System.Collections;
10using System.Collections.Generic;
20 internal sealed class StringKeyedCellView : IReadOnlyDictionary<string, Cell>
22 private readonly Dictionary<CellKey, Cell> store;
24 internal StringKeyedCellView(Dictionary<CellKey, Cell> store)
30 public Cell
this[
string key]
34 Cell.ResolveCellCoordinate(key, out
int col, out
int row);
35 return store[
new CellKey(col, row)];
42 get {
return store.Count; }
46 public IEnumerable<string> Keys
50 foreach (CellKey k
in store.Keys)
52 yield
return Cell.ResolveCellAddress(k.Column, k.Row);
58 public IEnumerable<Cell> Values
60 get {
return store.Values; }
64 public bool ContainsKey(
string key)
66 if (
string.IsNullOrEmpty(key))
72 Cell.ResolveCellCoordinate(key, out
int col, out
int row);
73 return store.ContainsKey(
new CellKey(col, row));
82 public bool TryGetValue(
string key, out Cell value)
84 if (
string.IsNullOrEmpty(key))
91 Cell.ResolveCellCoordinate(key, out
int col, out
int row);
92 return store.TryGetValue(
new CellKey(col, row), out value);
102 public IEnumerator<KeyValuePair<string, Cell>> GetEnumerator()
104 foreach (KeyValuePair<CellKey, Cell> kv
in store)
106 yield
return new KeyValuePair<string, Cell>(
107 Cell.ResolveCellAddress(kv.Key.Column, kv.Key.Row),
113 IEnumerator IEnumerable.GetEnumerator()
115 return GetEnumerator();