private IEnumerable<string> GetPropertiesAtEndOfPath(JsonDocument document, RavenJPath path) { var currentObject = document.DataAsJson.SelectToken(path); if (currentObject is RavenJObject) return (currentObject as RavenJObject).Keys; return new string[0]; }
private static Func<JsonDocument, object> CreateJPathDocumentExtractor(string binding) { try { var jpath = new RavenJPath(binding); return doc => GetTokenValue(doc.DataAsJson.SelectToken(jpath)); } catch (Exception) { return doc => "<<Invalid Binding Expression>>"; } }
/// <summary> /// Selects the token that matches the object path. /// </summary> /// <param name="path"> /// The object path from the current <see cref="RavenJToken"/> to the <see cref="RavenJToken"/> /// to be returned. This must be a string of property names or array indexes separated /// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or /// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic. /// </param> /// <param name="errorWhenNoMatch">A flag to indicate whether an error should be thrown if no token is found.</param> /// <returns>The <see cref="RavenJToken"/> that matches the object path.</returns> public RavenJToken SelectToken(RavenJPath path, bool errorWhenNoMatch) { return(path.Evaluate(this, errorWhenNoMatch)); }
private IEnumerable<string> GetProperties(string completedPropertyPath = "") { if (DocumentToSample != null) return GetPropertiesAtEndOfPath(DocumentToSample.Value); if (RecentDocuments != null && RecentDocuments.Count > 0) { var parsedPath = new RavenJPath(completedPropertyPath); var matchingProperties = RecentDocuments.SelectMany(doc => GetPropertiesAtEndOfPath(doc, parsedPath)).Distinct(); return matchingProperties; } return new string[0]; }
/// <summary> /// Selects the token that matches the object path. /// </summary> /// <param name="path"> /// The object path from the current <see cref="RavenJToken"/> to the <see cref="RavenJToken"/> /// to be returned. This must be a string of property names or array indexes separated /// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or /// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic. /// </param> /// <returns>The <see cref="RavenJToken"/> that matches the object path or a null reference if no matching token is found.</returns> public RavenJToken SelectToken(RavenJPath path) { return(SelectToken(path, false)); }
/// <summary> /// Selects the token that matches the object path. /// </summary> /// <param name="path"> /// The object path from the current <see cref="RavenJToken"/> to the <see cref="RavenJToken"/> /// to be returned. This must be a string of property names or array indexes separated /// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or /// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic. /// </param> /// <param name="errorWhenNoMatch">A flag to indicate whether an error should be thrown if no token is found.</param> /// <returns>The <see cref="RavenJToken"/> that matches the object path.</returns> public RavenJToken SelectToken(string path, bool errorWhenNoMatch) { var p = new RavenJPath(path); return(p.Evaluate(this, errorWhenNoMatch)); }
/// <summary> /// Selects the token that matches the object path. /// </summary> /// <param name="path"> /// The object path from the current <see cref="RavenJToken" /> to the <see cref="RavenJToken" /> /// to be returned. This must be a string of property names or array indexes separated /// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or /// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic. /// </param> /// <param name="errorWhenNoMatch">A flag to indicate whether an error should be thrown if no token is found.</param> /// <param name="createSnapshots">A flag to indicate whether token snapshots should be created.</param> /// <returns>The <see cref="RavenJToken" /> that matches the object path.</returns> public RavenJToken SelectToken(RavenJPath path, bool errorWhenNoMatch, bool createSnapshots = false) { return(path.Evaluate(this, errorWhenNoMatch, createSnapshots)); }
/// <summary> /// Selects the token that matches the object path. /// </summary> /// <param name="path"> /// The object path from the current <see cref="RavenJToken" /> to the <see cref="RavenJToken" /> /// to be returned. This must be a string of property names or array indexes separated /// by periods, such as <code>Tables[0].DefaultView[0].Price</code> in C# or /// <code>Tables(0).DefaultView(0).Price</code> in Visual Basic. /// </param> /// <param name="errorWhenNoMatch">A flag to indicate whether an error should be thrown if no token is found.</param> /// <param name="createSnapshots">A flag to indicate whether token snapshots should be created.</param> /// <returns>The <see cref="RavenJToken" /> that matches the object path.</returns> public RavenJToken SelectToken(string path, bool errorWhenNoMatch, bool createSnapshots = false) { var p = new RavenJPath(path); return(p.Evaluate(this, errorWhenNoMatch, createSnapshots)); }
private IEnumerable<string> GetProperties(string completedPropertyPath) { var parsedPath = new RavenJPath(completedPropertyPath); var matchingProperties = recentDocuments.SelectMany(doc => GetPropertiesAtEndOfPath(doc, parsedPath)).Distinct(); return matchingProperties; }