/// <inheritdoc /> public ConfigurationCollection Collection(ConfigurationQuery query) { var result = _jsonConfigStore.Read(query); if (!result.HasValues) { throw new InvalidOperationException($"A query for collection didn't return a collection. Query: '{query}'"); } throw new System.NotImplementedException(); }
/// <inheritdoc /> public JToken Read(ConfigurationQuery query) { // Parse out the query var queryValue = query.Value; var queryParts = queryValue.Split('.'); // Go through the reader to find the object requested _stream.Seek(0, SeekOrigin.Begin); while (_jsonReader.Read()) { // Check if we should skip/bail out var partIndex = _jsonReader.Depth - 1; if (partIndex < 0) { continue; } if (partIndex > queryParts.Length - 1) { break; } // Did we land on a property? if (_jsonReader.TokenType != JsonToken.PropertyName && _jsonReader.TokenType != JsonToken.StartObject) { continue; } // Get the requested property name var requestedPropertyName = queryParts[partIndex]; // Check if the current property name matches // the requested property name var path = _jsonReader.Path; var lastDotIndex = path.LastIndexOf('.'); var currentPropertyName = lastDotIndex == -1 ? path : path.Substring(lastDotIndex + 1); if (currentPropertyName != requestedPropertyName) { // Skip reading children _jsonReader.Skip(); continue; } // If we found a match and reached the end of parts collection if (partIndex == queryParts.Length - 1) { // this is the answer return(JToken.ReadFrom(_jsonReader)); } } return(null); }
/// <inheritdoc /> public ConfigurationValue Value(ConfigurationQuery query) { throw new NotImplementedException(); }
/// <inheritdoc /> public ConfigurationMap Map(ConfigurationQuery query) { throw new NotImplementedException(); }
/// <inheritdoc /> public ConfigurationCollection Collection(ConfigurationQuery query) { throw new NotImplementedException(); }