当前位置: 首页>>代码示例>>C#>>正文


C# Query.TryGetStructure方法代码示例

本文整理汇总了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;
        }
开发者ID:KirillOsenkov,项目名称:MyOwnSearchEngine,代码行数:10,代码来源:Factor.cs

示例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;
        }
开发者ID:KirillOsenkov,项目名称:MyOwnSearchEngine,代码行数:43,代码来源:Hex.cs

示例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;
        }
开发者ID:KirillOsenkov,项目名称:MyOwnSearchEngine,代码行数:14,代码来源:NumberList.cs

示例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;
        }
开发者ID:KirillOsenkov,项目名称:MyOwnSearchEngine,代码行数:21,代码来源:Unicode.cs

示例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;
        }
开发者ID:KirillOsenkov,项目名称:MyOwnSearchEngine,代码行数:92,代码来源:UnitConverter.cs


注:本文中的Query.TryGetStructure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。