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


C# JContainer.SelectToken方法代码示例

本文整理汇总了C#中JContainer.SelectToken方法的典型用法代码示例。如果您正苦于以下问题:C# JContainer.SelectToken方法的具体用法?C# JContainer.SelectToken怎么用?C# JContainer.SelectToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JContainer的用法示例。


在下文中一共展示了JContainer.SelectToken方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PositionI

 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.PositionI"/> class.
 /// </summary>
 /// <param name="obj">JSON Object.</param>
 public PositionI(JContainer obj)
 {
     X = (int)obj.SelectToken("X");
     Y = (int)obj.SelectToken("Y");
 }
开发者ID:Lopt,项目名称:ascendancy,代码行数:9,代码来源:PositionI.cs

示例2: CellPosition

 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.CellPosition"/> class.
 /// </summary>
 /// <param name="obj">JContainer Object.</param>
 public CellPosition(JContainer obj)
     : this((int)obj.SelectToken("CellX"),
     (int)obj.SelectToken("CellY"))
 {
 }
开发者ID:Lopt,项目名称:ascendancy,代码行数:9,代码来源:CellPosition.cs

示例3: MergeInto

        private static void MergeInto(JContainer left, JToken right)
        {
            foreach (var rightChild in right.Children<JProperty>())
            {
                var rightChildProperty = rightChild;
                var leftProperty = left.SelectToken(rightChildProperty.Name);

                if (leftProperty == null)
                {
                    left.Add(rightChild);
                }
                else
                {
                    var leftObject = leftProperty as JObject;

                    if (leftObject == null)
                    {
                        var leftParent = (JProperty) leftProperty.Parent;
                        leftParent.Value = rightChildProperty.Value;
                    }
                    else
                    {
                        MergeInto(leftObject, rightChildProperty.Value);
                    }
                }
            }
        }
开发者ID:ResourceDataInc,项目名称:Centroid,代码行数:27,代码来源:Config.cs

示例4: CheckApiErrorCode

        /// <summary>
        /// Check the 'error_code' field and throw the appropriate exception if non-null.
        /// </summary>
        /// <param name="apiResponse">Deserialized json response from a Keen API call.</param>
        public static void CheckApiErrorCode(JContainer apiResponse)
        {
            if (apiResponse == null) return;
            if (apiResponse is JArray) return;
            
            var errorCode = (string) apiResponse.SelectToken("$.error_code");

            if (errorCode != null)
            {
                var message = (string)apiResponse.SelectToken("$.message");
                switch (errorCode)
                {
                    case "InvalidApiKeyError":
                        throw new KeenInvalidApiKeyException(message);

                    case "ResourceNotFoundError":
                        throw new KeenResourceNotFoundException(message);

                    case "NamespaceTypeError":
                        throw new KeenNamespaceTypeException(message);

                    case "InvalidEventError":
                        throw new KeenInvalidEventException(message);

                    case "ListsOfNonPrimitivesNotAllowedError":
                        throw new KeenListsOfNonPrimitivesNotAllowedException(message);

                    case "InvalidBatchError":
                        throw new KeenInvalidBatchException(message);

                    case "InternalServerError":
                        throw new KeenInternalServerErrorException(message);

                    case "InvalidKeenNamespaceProperty":
                        throw new KeenInvalidKeenNamespacePropertyException(message);

                    default:
                        Debug.WriteLine("Unhandled error_code \"{0}\" : \"{1}\"", errorCode, message);
                        throw new KeenException(errorCode + " : " + message);
                }
            }
        }
开发者ID:iturpablo,项目名称:keen-sdk-net,代码行数:46,代码来源:KeenUtil.cs

示例5: RegionPosition

 /// <summary>
 /// Initializes a new instance of the <see cref="Core.Models.RegionPosition"/> class.
 /// </summary>
 /// <param name="obj">JContainer Object.</param>
 public RegionPosition(JContainer obj)
 {
     RegionX = (int)obj.SelectToken("RegionX");
     RegionY = (int)obj.SelectToken("RegionY");
 }
开发者ID:Lopt,项目名称:ascendancy,代码行数:9,代码来源:RegionPosition.cs


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