@@ -34,19 +34,32 @@ public bool ContainsKey(WritingSystemId key)
3434
3535 public void Add ( object key , object ? value )
3636 {
37- var valStr = value as string ?? throw new ArgumentException ( "unable to convert value to string" , nameof ( value ) ) ;
38- if ( key is WritingSystemId keyWs )
37+ WritingSystemId keyWs ;
38+ if ( key is WritingSystemId typed )
3939 {
40- Add ( keyWs , valStr ) ;
40+ keyWs = typed ;
4141 }
4242 else if ( key is string keyStr )
4343 {
44- Add ( keyStr , valStr ) ;
44+ keyWs = keyStr ;
4545 }
4646 else
4747 {
4848 throw new ArgumentException ( "unable to convert key to writing system id" , nameof ( key ) ) ;
4949 }
50+
51+ if ( value is string valueStr )
52+ {
53+ Add ( keyWs , valueStr ) ;
54+ }
55+ else if ( value is RichString valueRich )
56+ {
57+ Add ( keyWs , valueRich ) ;
58+ }
59+ else
60+ {
61+ throw new ArgumentException ( "unable to convert value to string" , nameof ( value ) ) ;
62+ }
5063 }
5164
5265 public bool Contains ( object key )
@@ -105,6 +118,26 @@ IDictionaryEnumerator IDictionary.GetEnumerator()
105118
106119 public void Remove ( object key )
107120 {
121+ if ( key is WritingSystemId keyWs )
122+ {
123+ Remove ( keyWs ) ;
124+ }
125+ else if ( key is string keyStr )
126+ {
127+ Remove ( keyStr ) ;
128+ }
129+ else
130+ {
131+ throw new ArgumentException ( $ "unable to convert key { key } to writing system id", nameof ( key ) ) ;
132+ }
133+ }
134+
135+ public bool Remove ( WritingSystemId key )
136+ {
137+ var containedKey = ContainsKey ( key ) ;
138+ var writingSystemHandle = lexboxLcmApi . GetWritingSystemHandle ( key ) ;
139+ multiString . set_String ( writingSystemHandle , null ) ;
140+ return containedKey ;
108141 }
109142
110143 public bool IsFixedSize => false ;
@@ -151,10 +184,6 @@ public void CopyTo(Array array, int index)
151184
152185 public bool IsReadOnly => false ;
153186
154- public bool Remove ( WritingSystemId key )
155- {
156- throw new NotSupportedException ( ) ;
157- }
158187
159188 public bool TryGetValue ( WritingSystemId key , out string value )
160189 {
0 commit comments