forked from influxdata/influxdb-client-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first draft of influx string functions, fixes influxdata#499
- Loading branch information
1 parent
30c1b61
commit 018f4bf
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace InfluxDB.Client.Linq.Internal.Expressions { | ||
internal class StringFunction : IExpressionPart { | ||
private readonly string functionName; | ||
private readonly IEnumerable<IExpressionPart> expressionParts; | ||
private readonly IEnumerable<IExpressionPart> expressionPartsPar2; | ||
|
||
internal StringFunction(string functionName, IEnumerable<IExpressionPart> expressionParts, IEnumerable<IExpressionPart> expressionPartsPar2) { | ||
this.functionName = functionName; | ||
this.expressionParts = expressionParts; | ||
this.expressionPartsPar2 = expressionPartsPar2; | ||
} | ||
|
||
public void AppendFlux(StringBuilder builder) { | ||
builder.Append("strings."); | ||
builder.Append(functionName); | ||
builder.Append("(v: "); | ||
foreach (var expressionPart in expressionParts) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
if (functionName == "containsStr") | ||
{ | ||
builder.Append(", substr: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
else if (functionName == "hasPrefix") { | ||
builder.Append(", prefix: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
else if (functionName == "hasSuffix") { | ||
builder.Append(", suffix: "); | ||
foreach (var expressionPart in expressionPartsPar2) { | ||
expressionPart.AppendFlux(builder); | ||
} | ||
} | ||
builder.Append(")"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters