@@ -16,6 +16,8 @@ public class IndexStorageSchema<TIndexItem> : IIndexSchema<TIndexItem>
1616 {
1717 private readonly string _extentions = "ws" ;
1818 private readonly int _version = 1 ;
19+ private static readonly JsonSerializerOptions _jsonSerializerOptions = new ( ) { WriteIndented = true } ;
20+ private static readonly JsonSerializerOptions _jsonDeserializerOptions = new ( ) { PropertyNameCaseInsensitive = true } ;
1921
2022 /// <summary>
2123 /// Returns the file name.
@@ -61,9 +63,8 @@ public bool HasSchemaChanged()
6163 var currentSchema = GetSchema ( ) ;
6264 var storedSchema = Read ( ) ;
6365
64- var options = new JsonSerializerOptions { WriteIndented = true } ;
65- var currentJson = JsonSerializer . Serialize ( currentSchema , options ) ;
66- var storedJson = JsonSerializer . Serialize ( storedSchema , options ) ;
66+ var currentJson = JsonSerializer . Serialize ( currentSchema , _jsonSerializerOptions ) ;
67+ var storedJson = JsonSerializer . Serialize ( storedSchema , _jsonSerializerOptions ) ;
6768
6869 return ! currentJson . Equals ( storedJson ) ;
6970 }
@@ -133,23 +134,21 @@ private object GetType(PropertyInfo property)
133134 private void Write ( )
134135 {
135136 var schema = GetSchema ( ) ;
136- var options = new JsonSerializerOptions { WriteIndented = true } ;
137- var json = JsonSerializer . Serialize ( schema , options ) ;
137+ var json = JsonSerializer . Serialize ( schema , _jsonSerializerOptions ) ;
138138
139139 File . WriteAllText ( FileName , json ) ;
140140 }
141141
142142 /// <summary>
143143 /// Reads the object schema from the storage medium.
144144 /// </summary>
145- /// /// <returns>
145+ /// <returns>
146146 /// The deserialized schema as an dynamic object.
147147 /// </returns>
148148 private dynamic Read ( )
149149 {
150150 var json = File . ReadAllText ( FileName ) ;
151- var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true } ;
152- var schema = JsonSerializer . Deserialize < dynamic > ( json , options ) ;
151+ var schema = JsonSerializer . Deserialize < dynamic > ( json , _jsonDeserializerOptions ) ;
153152
154153 return schema ;
155154 }
@@ -169,7 +168,7 @@ public void Drop()
169168 /// </summary>
170169 public virtual void Dispose ( )
171170 {
172-
171+ GC . SuppressFinalize ( this ) ;
173172 }
174173 }
175174}
0 commit comments