本文整理汇总了C#中QueryToken.SubTokens方法的典型用法代码示例。如果您正苦于以下问题:C# QueryToken.SubTokens方法的具体用法?C# QueryToken.SubTokens怎么用?C# QueryToken.SubTokens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryToken
的用法示例。
在下文中一共展示了QueryToken.SubTokens方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryTokenBuilderOrders_SubTokensEvent
private List<QueryToken> QueryTokenBuilderOrders_SubTokensEvent(QueryToken token)
{
var cr = (UserChartEntity)DataContext;
if (cr == null || QueryDescription == null)
return new List<QueryToken>();
return token.SubTokens(QueryDescription, SubTokensOptions.CanElement | (cr.GroupResults ? SubTokensOptions.CanAggregate : 0));
}
示例2: QueryTokenCombo
static MvcHtmlString QueryTokenCombo(this HtmlHelper helper, QueryToken previous, QueryToken selected, int index, Context context, QueryTokenBuilderSettings settings)
{
if (previous != null && AllowSubTokens != null && !AllowSubTokens(previous))
return MvcHtmlString.Create("");
var queryTokens = previous.SubTokens(settings.QueryDescription, settings.CanAggregate);
if (queryTokens.IsEmpty())
return new HtmlTag("input")
.Attr("type", "hidden")
.IdName(context.Compose("ddlTokensEnd_" + index))
.Attr("disabled", "disabled")
.Attr("data-parenttoken", previous == null ? "" : previous.FullKey());
var options = new HtmlStringBuilder();
options.AddLine(new HtmlTag("option").Attr("value", "").SetInnerText("-").ToHtml());
foreach (var qt in queryTokens)
{
var option = new HtmlTag("option")
.Attr("value", previous == null ? qt.FullKey() : qt.Key)
.SetInnerText((previous == null && qt.Parent != null ? " - " : "") + qt.ToString());
if (selected != null && qt.Key == selected.Key)
option.Attr("selected", "selected");
option.Attr("title", qt.NiceTypeName);
option.Attr("style", "color:" + qt.TypeColor);
if (settings.Decorators != null)
settings.Decorators(qt, option);
options.AddLine(option.ToHtml());
}
HtmlTag dropdown = new HtmlTag("select")
.Class("form-control")
.IdName(context.Compose("ddlTokens_" + index))
.InnerHtml(options.ToHtml())
.Attr("data-parenttoken", previous == null ? "" : previous.FullKey());
if (selected != null)
{
dropdown.Attr("title", selected.NiceTypeName);
dropdown.Attr("style", "color:" + selected.TypeColor);
}
return dropdown.ToHtml();
}
示例3: qtbFilters_SubTokensEvent
List<QueryToken> qtbFilters_SubTokensEvent(QueryToken token)
{
var cr = (ChartRequest)DataContext;
if (cr == null || chartRenderer.Description == null)
return new List<QueryToken>();
return token.SubTokens(chartRenderer.Description, SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement | (cr.GroupResults ? SubTokensOptions.CanAggregate : 0));
}
示例4: tokenBuilder_SubTokensEvent
List<QueryToken> tokenBuilder_SubTokensEvent(QueryToken arg)
{
string canColumn = QueryUtils.CanColumn(arg);
btCreateColumn.IsEnabled = string.IsNullOrEmpty(canColumn);
btCreateColumn.ToolTip = canColumn;
string canFilter = QueryUtils.CanFilter(arg);
btCreateFilter.IsEnabled = string.IsNullOrEmpty(canFilter);
btCreateFilter.ToolTip = canFilter;
return arg.SubTokens(Description, SubTokensOptions.CanAnyAll | SubTokensOptions.CanElement);
}
示例5: TryParseRemember
static bool TryParseRemember(Replacements replacements, string tokenString, QueryDescription qd, SubTokensOptions options, out QueryToken result)
{
string[] parts = tokenString.Split('.');
result = null;
for (int i = 0; i < parts.Length; i++)
{
string part = parts[i];
QueryToken newResult = QueryUtils.SubToken(result, qd, options, part);
if (newResult != null)
{
result = newResult;
}
else
{
if (i == 0)
{
var entity = QueryUtils.SubToken(result, qd, options, "Entity");
QueryToken newSubResult = QueryUtils.SubToken(entity, qd, options, part);
if (newSubResult != null)
{
result = newSubResult;
continue;
}
}
if (Replacements.AutoReplacement != null)
{
Replacements.Selection? sel = Replacements.AutoReplacement(part, result.SubTokens(qd, options).Select(a => a.Key).ToList());
if (sel != null && sel.Value.NewValue != null)
{
newResult = QueryUtils.SubToken(result, qd, options, sel.Value.NewValue);
if (newResult != null)
{
result = newResult;
continue;
}
}
}
string key = result == null ? QueryKey(qd.QueryName) : TypeKey(result.Type);
Dictionary<string, string> dic = replacements.TryGetC(key);
if (dic == null)
return false;
string remainging = parts.Skip(i).ToString(".");
string old = dic.Keys.OrderByDescending(a => a.Length).FirstOrDefault(s => remainging.StartsWith(s));
if (old == null)
return false;
var subParts = dic[old].Let(s => s.HasText() ? s.Split('.') : new string[0]);
for (int j = 0; j < subParts.Length; j++)
{
string subPart = subParts[j];
QueryToken subNewResult = QueryUtils.SubToken(result, qd, options, subPart);
if (subNewResult == null)
return false;
result = subNewResult;
}
i += (old == "" ? 0 : old.Split('.').Length) - 1;
}
}
return true;
}
示例6: SelectInteractive
static UserAssetTokenAction? SelectInteractive(ref QueryToken token, QueryDescription qd, SubTokensOptions options, bool allowRemoveToken, bool allowReGenerate)
{
var top = Console.CursorTop;
try
{
if (Console.Out == null)
throw new InvalidOperationException("Impossible to synchronize without interactive Console");
var subTokens = token.SubTokens(qd, options).OrderBy(a => a.Parent != null).ThenBy(a => a.Key).ToList();
int startingIndex = 0;
SafeConsole.WriteLineColor(ConsoleColor.Cyan, " " + token.Try(a => a.FullKey()));
bool isRoot = token == null;
retry:
int maxElements = Console.LargestWindowHeight - 11;
subTokens.Skip(startingIndex).Take(maxElements)
.Select((s, i) => "- {1,2}: {2} ".FormatWith(i + " ", i + startingIndex, ((isRoot && s.Parent != null) ? "-" : "") + s.Key)).ToConsole();
Console.WriteLine();
int remaining = subTokens.Count - startingIndex - maxElements;
if (remaining > 0)
SafeConsole.WriteLineColor(ConsoleColor.White, "- +: Show more values ({0} remaining)", remaining);
if (token != null)
{
SafeConsole.WriteLineColor(ConsoleColor.White, "- b: Back");
SafeConsole.WriteLineColor(ConsoleColor.Green, "- c: Confirm");
}
SafeConsole.WriteLineColor(ConsoleColor.Yellow, "- s: Skip entity");
if (allowRemoveToken)
SafeConsole.WriteLineColor(ConsoleColor.DarkRed, "- r: Remove token");
if (allowReGenerate)
SafeConsole.WriteLineColor(ConsoleColor.Magenta, "- g: Generate from default template");
SafeConsole.WriteLineColor(ConsoleColor.Red, "- d: Delete entity");
while (true)
{
string answer = Console.ReadLine();
if (answer == null)
throw new InvalidOperationException("Impossible to synchronize interactively without Console");
answer = answer.ToLower();
if (answer == "+" && remaining > 0)
{
startingIndex += maxElements;
goto retry;
}
if (answer == "s")
return UserAssetTokenAction.SkipEntity;
if (answer == "r" && allowRemoveToken)
return UserAssetTokenAction.RemoveToken;
if (answer == "d")
return UserAssetTokenAction.DeleteEntity;
if (answer == "g")
return UserAssetTokenAction.ReGenerateEntity;
if (token != null)
{
if (answer == "c")
return UserAssetTokenAction.Confirm;
if (answer == "b")
{
token = token.Parent;
return null;
}
}
int option = 0;
if (int.TryParse(answer, out option))
{
token = subTokens[option];
return null;
}
Console.WriteLine("Error");
}
}
finally
{
Clean(top, Console.CursorTop);
}
}
示例7: QueryTokenBuilder_SubTokensEvent
private List<QueryToken> QueryTokenBuilder_SubTokensEvent(QueryToken token)
{
return token.SubTokens(QueryDescription, SubTokensOptions.CanElement);
}