/// <summary> /// Called when the configuration source has been requested and must prepare for resolution. /// </summary> /// <exception cref="ConfigurationException"></exception> public void Load() { sync.EnterWriteLock(); try { switch (source) { case JsonSource.File: using (var reader = new StreamReader(path.FullName)) using (var content = new JsonTextReader(reader)) { document = serializer.Deserialize <JObject>(content); } break; case JsonSource.Stream: using (var reader = new StreamReader(stream)) using (var content = new JsonTextReader(reader)) { document = serializer.Deserialize <JObject>(content); } break; } } catch (Exception ex) { throw new ConfigurationException($"Cannot load a {source.ToString().ToLower()} JSON document", ex); } finally { sync.ExitWriteLock(); } }