本文整理汇总了C#中Query.TryGetStructure方法的典型用法代码示例。如果您正苦于以下问题:C# Query.TryGetStructure方法的具体用法?C# Query.TryGetStructure怎么用?C# Query.TryGetStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query.TryGetStructure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetResult
public string GetResult(Query query)
{
var integer = query.TryGetStructure<Integer>();
if (integer != null && integer.Value > -10000000 && integer.Value < 10000000)
{
return GetResult((int)integer.Value);
}
return null;
}
示例2: GetResult
public string GetResult(Query query)
{
var integer = query.TryGetStructure<Integer>();
if (integer != null)
{
return GetResult(integer.Value);
}
var separatedList = query.TryGetStructure<SeparatedList>();
if (separatedList != null && separatedList.Count >= 2)
{
var number = separatedList.TryGetStructure<Integer>(0);
if (number != null)
{
var keyword1 = separatedList.TryGetStructure<Keyword>(1);
if (keyword1 != null)
{
if (keyword1 == "hex" && separatedList.Count == 2)
{
return GetResult(number.Value);
}
if (separatedList.Count == 3 &&
(keyword1 == "in" || keyword1 == "to") &&
separatedList.TryGetStructure<Keyword>(2) == "hex")
{
return GetResult(number.Value);
}
}
}
else
{
number = separatedList.TryGetStructure<Integer>(1);
var keyword1 = separatedList.TryGetStructure<Keyword>(0);
if (number != null && keyword1 != null && keyword1 == "hex" && separatedList.Count == 2)
{
return GetResult(number.Value);
}
}
}
return null;
}
示例3: GetResult
public string GetResult(Query query)
{
var list = query.TryGetStructure<SeparatedList>();
if (list != null)
{
var numbersList = list.GetStructuresOfType<Double>();
if (numbersList != null && numbersList.Count == list.Count)
{
return GetResult(numbersList);
}
}
return null;
}
示例4: GetResult
public string GetResult(Query query)
{
var input = query.OriginalInput;
var bytes = query.TryGetStructure<byte[]>();
if (bytes != null)
{
return GetResult(bytes);
}
if (input.StartsWith("\\u", StringComparison.OrdinalIgnoreCase) || input.StartsWith("U+", StringComparison.OrdinalIgnoreCase))
{
int number;
if (input.Substring(2).TryParseHex(out number) && IsUnicodeCodepoint(number))
{
return GetResult(number);
}
}
return null;
}
示例5: GetResult
public string GetResult(Query query)
{
var tuple = query.TryGetStructure<Tuple<Double, Unit>>();
if (tuple != null)
{
return GetResult(tuple.Item1.Value, tuple.Item2);
}
var list = query.TryGetStructure<SeparatedList>();
if (list != null && list.SeparatorChar == ' ')
{
if (list.Count == 2 || list.Count == 4)
{
var firstNumber = list.TryGetStructure<Double>(0);
var unit = list.TryGetStructure<Unit>(1);
if (firstNumber != null && unit != null)
{
if (list.Count == 2)
{
return GetResult(firstNumber.Value, unit);
}
var keyword = list.TryGetStructure<Keyword>(2);
var tounit = list.TryGetStructure<Unit>(3);
if ((keyword == "in" || keyword == "to") && tounit != null)
{
return GetResult(firstNumber.Value, unit, tounit);
}
}
}
if (list.Count == 3)
{
var firstTuple = list.TryGetStructure<Tuple<Double, Unit>>(0);
var keyword = list.TryGetStructure<Keyword>(1);
var toUnit = list.TryGetStructure<Unit>(2);
if (firstTuple != null &&
(keyword == "in" || keyword == "to") &&
toUnit != null)
{
return GetResult(firstTuple.Item1.Value, firstTuple.Item2, toUnit);
}
}
if (list.Count == 2)
{
var firstTuple = list.TryGetStructure<Tuple<Double, Unit>>(0);
var secondTuple = list.TryGetStructure<Tuple<Double, Unit>>(1);
if (firstTuple != null &&
secondTuple != null &&
firstTuple.Item2 == Units.Foot &&
secondTuple.Item2 == Units.Inch)
{
return GetResult(firstTuple.Item1.Value * 12 + secondTuple.Item1.Value, Units.Inch);
}
var secondNumber = list.TryGetStructure<Double>(1);
if (firstTuple != null &&
firstTuple.Item2 == Units.Foot &&
secondNumber != null)
{
return GetResult(firstTuple.Item1.Value * 12 + secondNumber.Value, Units.Inch);
}
}
if (list.Count == 3 || list.Count == 4)
{
var firstNumber = list.TryGetStructure<Double>(0);
var unit = list.TryGetStructure<Unit>(1);
var secondNumber = list.TryGetStructure<Double>(2);
if (list.Count == 3 &&
firstNumber != null &&
unit == Units.Foot &&
secondNumber != null)
{
return GetResult(firstNumber.Value * 12 + secondNumber.Value, Units.Inch);
}
if (list.Count == 4 &&
firstNumber != null &&
unit == Units.Foot &&
secondNumber != null &&
list.TryGetStructure<Unit>(3) == Units.Inch)
{
return GetResult(firstNumber.Value * 12 + secondNumber.Value, Units.Inch);
}
}
}
return null;
}